2015-05-02 20:55
浏览 52

从stackoverflow.com解析rss时出错。 在PHP中使用SimpleXML

I was trying to parse the rss of the tag PHP, from http://stackoverflow.com and tried to use something other than DOM Model, So I looked into SimpleXML. THis is my code:

    $xml = file_get_contents('https://stackoverflow.com/feeds/tag/php');
    $loaded = simplexml_load_string($xml) or die("There is a problem");
    $str1 = $loaded["entry"]["entry"][0]->title;
    echo $str1;

But nothing is displayed on the screen, and also no error is displayed! The sample data from https://stackoverflow.com/feeds/tag/php can be found at http://gourabt2.cloudapp.net/sample-data/sample_data.xml

Any Help would be very much appreciated! Thanks! Cheers!

图片转代码服务由CSDN问答提供 功能建议

我试图从 http://stackoverflow.com 并试图使用除DOM模型以外的东西,所以我研究了SimpleXML。 这是我的代码:</ p>

 $ xml = file_get_contents('https://stackoverflow.com/feeds/tag  / php'); 
 $ loaded = simplexml_load_string($ xml)或die(“有问题”); 
 $ str1 = $ loaded [“entry”] [“entry”] [0]  - &gt; title  ; 
 echo $ str1; 
 </ code> </ pre> 

但屏幕上没有显示任何内容,也没有显示错误! 来自<的示例数据 可以在 https://stackoverflow.com/feeds/tag/php /gourabt2.cloudapp.net/sample-data/sample_data.xml"rel =“nofollow noreferrer”> http://gourabt2.cloudapp.net/sample-data/sample_data.xml </ p> \ n

非常感谢任何帮助! 谢谢! 干杯!</ p> </ div>

3条回答 默认 最新

相关推荐 更多相似问题