Thursday, April 20, 2006

simple XML in php5

In php5 there is a new simple way to process or create XML files , It's the SimpleXML
It'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 ( )


$xml = simple_xml_file( '' ) ;

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


foreach ($xml->item as $news)
$news->title . '

there is simpler than that ?!