[英]Trouble with getting an xml file with PHP
当我查看此页面的源代码http://feeds.feedburner.com/Koreus-articles时 ,它将按预期显示源代码,这是一个干净的xml文件
但是,当我尝试与此:
<?php
$content = file_get_contents('http://feeds.feedburner.com/Koreus-articles');
echo $content;
?>
我得到了这个可怕的东西: http : //pastebin.com/s263M6sC我只是不明白发生了什么。
file_get_contents()可与任何其他简单页面(例如www.example.com)一起正常工作,但不能与该xml文件兼容。
任何帮助表示赞赏,谢谢!
只需将您的file_get_contents()
调用更改为simplexml_load_file()
,然后可以使用print_r
输出整个对象:
$content = simplexml_load_file('http://feeds.feedburner.com/Koreus-articles');
echo "<pre>";
print_r($content);
echo "</pre>";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.