我試圖解析http://api.hostip.info/?ip=12.215.42.19與SimpleXML的xml響應,但我似乎無法得到它的工作。hostip.info - 使用SimpeXML解析API響應
響應
<?xml version="1.0" encoding="ISO-8859-1" ?>
<HostipLookupResultSet version="1.0.1" 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.1.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>
<ip>12.215.42.19</ip>
<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>
有人可以幫助我訪問例如主機IP> ipLocation> pointProperty>點提前>座標
謝謝!
可能重複:使用含有XML命名空間的工作](http://stackoverflow.com/questions/2014835/simplexml-working-with-xml-containing-namespaces) – Gordon 2011-01-28 12:44:13
偉大的,我認爲這將有助於:) – n00b 2011-01-28 12:54:15