使用PHP获取xml文件时出现问题

时间:2015-01-18 22:14:59

标签: php xml

当我查看此页面的源代码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文件。

感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

只需将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>";
相关问题