> Matthew Sims wrote:
>
>> My fault, I should have been more specific. An RSS reader. :) I was
>> using
>> xmlParser-0.3 and feedParser-0.5 to display news sites. Since I've
>> converted to PHP5, they no longer work for me.
>
> definitely a combination of simplexml and DOM would work.  You need DOM
> in order to determine what the name of the root node's namespace is to
> find RSS 1.0.
>
> http://php.net/simplexml
> http://php.net/DOM
>
> for example:
>
> <?php
> $rss = simplexml_load_file('http://www.example.com/blah.rss');
> $dom = new domdocument("1.0");
> $dom_rss = $dom->importnode($rss, true);
> $dom_rss = $dom->appendchild($rss);
> if ($dom_rss->namespaceURI == '') {
>      $rssversion = '1.0';
> } else {
>      $rssversion = $rss['version'];
> }
> switch ($rssversion) {
>      case '1.0' :
>      case '2.0' :
>          if (isset($rss->channel->pubDate)) {
>              echo "Publication Date: " . $rss->channel->pubDate . "<br
> />";
>          }
>
>      case '0.91' :
>      case '0.92' :
>      case '0.93' :
>      case '0.94' :
>          echo '<a href="';
>          echo $rss->channel->link;
>          echo '">' . $rss->channel->title . '</a><br />';
>          foreach ($rss->channel->item as $item) {
>              echo $item->title . '<br />';
>              echo '<a href="';
>              echo $item->link;
>              echo '">' . $item->description . '</a><br />';
>          }
>      break;
> }
> ?>
>
> Of course, the full range RSS tags are available to you as object
> properties, and attributes as array access (like $rss['version'])
>
> Greg
>

Very nice, thank you. This should get my feet wet with a little XML.

-- 
--Matthew Sims
--<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to