News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Stuart Herbert's Blog:
Using SimpleXML To Parse RSS Feeds
January 11, 2007 @ 09:48:00

In PHP5, SimpleXML reigns as king when you just need a quick, light, easy way to pull in the data from an XML feed, especially RSS feeds. Stuart Herbert found this out and is sharing his knowledge in a new post to his blog showing how he worked with SimpleXML and namespaces to combine feeds into a "multi-blog".

I can fake the multiblog by putting several different blogs on the site, and generating a homepage from the RSS feeds of the individual blogs. Should be simple enough, and it sounds like the perfect nail to hit with the SimpleXML hammer of PHP 5 :) Funnily enough, in work last week we were wondering whether you could use SimpleXML with XML namespaces (alas, we still use PHP 4 at work atm), so armed with the perfect excuse, I set to work.

He follows the path he took - pulling in the feeds, using the information inside the SimpleXML element. The tricky part came in when he introduced the namespaces into the SimpleXML imports. He shows how to work with it rather than against it by using an array of namespace values and use the CDTA blocks in the results. The post wraps up with a full code listing of this handy little application.

0 comments voice your opinion now!
xml parse rss simplexml namespace cdata xml parse rss simplexml namespace cdata


blog comments powered by Disqus

Similar Posts

David Sklar\'s Blog: Parsing Reasonably-sized HTTP Responses

Ben Ramsey\'s Blog: Add Children with SimpleXML

Gonzalo Ayuso's Blog: First impressions about namespaces in PHP

Lorna Mitchell's Blog: 3 Ways to Access a Namespaced PHP Class

Adam Trachtenberg's Blog: PHP Trivia Contest: DOM + Default Namespaces


Community Events





Don't see your event here?
Let us know!


version release composer install community update laravel podcast framework introduction opinion tool voicesoftheelephpant interview symfony language library package series security

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework