simple XML in php5
In php5 there is a new simple way to process or create XML files , It's the SimpleXMLIt's not the powerful or the best but it's the simplest and the best choice for working with simple xml files like RSS.
here I will show you how you can read a RSS feed in simple steps with SimpleXML
first, we will start a new Object that's takes the path of the XML file, we will read the arabic bbc news feed so we will use this url ( http://newsrss.bbc.co.uk/rss/arabic/news/rss.xml )
CODE
$xml = simple_xml_file( 'http://newsrss.bbc.co.uk/rss/arabic/news/rss.xml' ) ;
so now we have the file loaded into a new Object called $xml
then we will loop through the file to get the values of the targeted elements
there is simpler than that ?!
CODE
foreach ($xml->item as $news)
{
echo $news->title . '
\n\r';
}
there is simpler than that ?!
0 Comments:
Post a Comment
<< Home