i am trying to read the yahoo rss (http://news.yahoo.com/rss/us) in php using the xml function
this is myvery simple code:
$xml = simplexml_load_file('xml.xml');
var_dump($xml['channel']);
but i shows NULL:
adam@cka: php test.php
NULL
is my XML broken? or there's a better function in php to read xml file?
i can see the elment exists in the XML file and i downloaded the file correctly in my computer.
SimpleXML returns an object, not an array. Try this:
<?php
$xml = simplexml_load_file('http://news.yahoo.com/rss/us');
var_dump($xml->channel);
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With