我做了这个简单的测试:
<?php
$feed = simplexml_load_file('http://feeds.livep2000.nl');
echo "<pre>".print_r($feed,true)."</pre>";
?>
它不显示地理标签的原因是因为它们不存在于 $feed 变量中。
代码的示例输出:
[item] => Array
(
[0] => SimpleXMLElement Object
(
[title] => SimpleXMLElement Object
(
)
[link] => http://monitor.livep2000.nl?SPI=1311111908030208
[description] => SimpleXMLElement Object
(
)
[pubDate] => Mon, 11 Nov 2013 19:08:03 +0100
[guid] => 1311111908030208
)
[1] => SimpleXMLElement Object
(
[title] => SimpleXMLElement Object
(
)
[link] => http://monitor.livep2000.nl?SPI=1311111908010223
[description] => SimpleXMLElement Object
(
)
[pubDate] => Mon, 11 Nov 2013 19:08:01 +0100
[guid] => 1311111908010223
)
现在您可以通过这种方式访问 Lat 和 Long 值:
$feed = simplexml_load_file('http://feeds.livep2000.nl');
foreach ($feed->channel->item as $item) {
$ns_dc = $item->children('http://www.w3.org/2003/01/geo/wgs84_pos#');
echo "Lat: ".$ns_dc->lat." | Long: ".$ns_dc->long."</br>";
}
以及脚本的正确输出:
Lat: 52.5123727 | Long: 4.9528409
Lat: 51.52939 | Long: 5.0269987
Lat: 52.4189359 | Long: 4.8860944
Lat: 52.5146807 | Long: 4.7027031