PHP DOMXML: Constructing an (Atom) RSS Feed
// September 21st, 2008 // No Comments » // PHP, Programming
There’s no doubt an easier way of parsing an RSS feed (xml) than by using DOM XML, but I’m here to show you how to do it the hard way. Infact, you could learn a thing or two by taking the harder, yet still logical, routes in programming.
The Basic Elements of an Atom RSS Feed
First, you have the “rss” element that defines the version and the xmlns, as shown below:
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
Next comes your “channel” element – essentially the root of your RSS feed – which contains all the RSS feed information, including content. The channel element does not have any attributes, only child elements. The child elements consist of: title, description, lastBuildDate, language, ttl, atom:link, and the RSS item(s) – as shown below:
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Example RSS Feed</title>
<description>A mock-up RSS feed.</description>
<lastBuildDate>Sun, 21 Sep 2008 18:56 -0500</lastBuildDate>
<language>en-us</language>
<ttl>60</ttl>
<atom:link href="http://examplesite.com/feed/news.rss" rel="self" type="application/rss+xml"/>
</channel>
</rss>




