danlayton00 Posted September 16, 2009 Share Posted September 16, 2009 I am trying to use an XML file this is the file below how do I get attributes into array? <?xml version="1.0" encoding="ISO-8859-1" ?> <HostipLookupResultSet version="1.0.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.hostip.info/api/hostip-1.0.0.xsd"> <gml:description>This is the Hostip Lookup Service</gml:description> <gml:name>hostip</gml:name> <gml:boundedBy> <gml:Null>inapplicable</gml:Null> </gml:boundedBy> <gml:featureMember> <Hostip> <gml:name>Sugar Grove, IL</gml:name> <countryName>UNITED STATES</countryName> <countryAbbrev>US</countryAbbrev> <!-- Co-ordinates are available as lng,lat --> <ipLocation> <gml:pointProperty> <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:coordinates>-88.4588,41.7696</gml:coordinates> </gml:Point> </gml:pointProperty> </ipLocation> </Hostip> </gml:featureMember> </HostipLookupResultSet> Link to comment https://forums.phpfreaks.com/topic/174515-xmlsimple/ Share on other sites More sharing options...
Mark Baker Posted September 16, 2009 Share Posted September 16, 2009 There are no attributes in this xml file. $xml = simplexml_load_file($pFilename); $namespaces = $xml->getNamespaces(true); foreach ($xml->Hostip as $hostip) { $hostip_gml = $hostip->children($namespaces['gml']); echo $hostip->countryName; echo $hostip->countryAbbrev; echo $hostip_gml->name; } Link to comment https://forums.phpfreaks.com/topic/174515-xmlsimple/#findComment-919785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.