0
我试图穿越这个XML提要:PHP的SimpleXML穿越
http://www.goonersworld.co.uk/forum/feed.php
使用此代码:
$data = file_get_contents('http://www.goonersworld.co.uk/forum/feed.php');
//$data = str_replace("content:encoded>","content>",$data);
$xml = simplexml_load_string($data,'SimpleXMLElement', LIBXML_NOCDATA);
foreach ($xml->feed->entry as $stories) {
echo $stories->published."<br>";
}
但我发现了什么回来。对我来说,它看起来像$ xml-> feed-> entry->发布,但我错过了什么?
的关键是不是''和''处于同一级别,而是变量'$ xml'代表XML节点''(文档的根节点),所以'$ xml-> feed-> entry'需要一个看起来像' ...'的XML(或“ ...') –
IMSoP