简体   繁体   中英

Trouble with getting an xml file with PHP

When I'm viewing the source code of this page http://feeds.feedburner.com/Koreus-articles , it shows the source code as expected, a clean xml file

However when I'm trying with this :

<?php
    $content = file_get_contents('http://feeds.feedburner.com/Koreus-articles');
    echo $content;
?>

I'm getting this horrible thing : http://pastebin.com/s263M6sC i just don't get what just happened.

file_get_contents() works fine with any other simple page such as www.example.com, just not that xml file.

Any help appreciated, thanks !

Just change your file_get_contents() call to a simplexml_load_file() and then you can output the entire object with print_r :

$content = simplexml_load_file('http://feeds.feedburner.com/Koreus-articles');
echo "<pre>";
print_r($content);
echo "</pre>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM