Forum Moderators: coopster

Message Too Old, No Replies

The best 3rd-party RSS/ATOM feed parsers?

         

toplisek

8:56 am on Jan 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I like to define the best possible 3rd-party RSS/ATOM feed parsers.
1. Which are the best as I see some do not read Author item.
Is this usual to cut some items within XML feed data?

vincevincevince

11:58 am on Jan 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is best to use DOMDocument, see here: [php.net...]

It does not cut anything

toplisek

12:32 pm on Jan 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I put example XML:
?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">


<channel>
<title>News ticket system</title>
<item>
<title>Google marketing</title>
<link>http://www.mydomain.com/</link>
<description>Short description</description>
<pubDate>Mon, 24 Jan 2011 14:20:01 GMT</pubDate>
<author>Mydomain.com</author>
</item>

</channel>
</rss>

Is correct code with DOM:
<?php

// Create a new DOMDocument object
$xmlDoc = new DOMDocument();

// Load XML from a file
$xmlDoc->load("myfiledom.xml");

// Search for all elements with tag name 'title'
$titles = $xmlDoc->getElementsByTagName('title');

// loop through titles and print all items
foreach ($titles AS $key => $title) {

// search for element 'item'
$item = $xmlDoc->getElementsByTagName('item');

// search for element 'link'
$link = $xmlDoc->getElementsByTagName('link');

// search for element 'pubDate'
$pubDate = $xmlDoc->getElementsByTagName('pubDate');

// search for element 'description'
$description = $xmlDoc->getElementsByTagName('description');


// search for element 'author'
$price = $xmlDoc->getElementsByTagName('author');

// print node value for all items
echo $title->item($key)->nodeValue . " = " . $item->item($key)->nodeValue . "<br />";
$link->item($key)->nodeValue . "<br />";
$pubDate->item($key)->nodeValue . "<br />";
$description->item($key)->nodeValue . "<br />";
$author->item($key)->nodeValue . "<br />";
}
?>