2015-07-28 92 views
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->发布,但我错过了什么?

回答

0

好的,所以我想通了。如果它帮助其他人,它是由PHPBB(公告板)生成的源。

我一直在寻找的实际结构很干脆:

foreach ($xml->entry as $stories) { 

       echo $stories->published."<br>"; 
      } 

饲料和入境没有看起来是在XML格式相同的水平,但他们:-(

+1

的关键是不是''和''处于同一级别,而是变量'$ xml'代表XML节点''(文档的根节点),所以'$ xml-> feed-> entry'需要一个看起来像' ...'的XML(或“ ...') – IMSoP