FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

simpleXML Tutorial Learn to Parse XML Files and RSS Feeds

Published :
Author :
Adam Khoury
Learn to parse XML based feeds or data using PHP and a for loop. You can target any popular website RSS and rip data straight from their feeds using minimal code that is very easy to understand. We use the simplexml_load_file function to make an XML object out of the XML file online. An XML object that can then be parsed easily enough with a PHP for loop. The simplexml_load_file function is part of the simpleXML extension of PHP. <?php $html = ""; $url = "http://www.developphp.com/feed_all_vids.php"; $xml = simplexml_load_file($url); for($i = 0; $i < 10; $i++){ $title = $xml->channel->item[$i]->title; $link = $xml->channel->item[$i]->link; $description = $xml->channel->item[$i]->description; $pubDate = $xml->channel->item[$i]->pubDate; $html .= "<a href='$link'><h3>$title</h3></a>"; $html .= "$description"; $html .= "<br />$pubDate<hr />"; } echo $html; ?>