Re: XML Reader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, December 29, 2005 12:40 am, benc11@xxxxxxxxx wrote:
> Is there any easy php script to run to view an xml file such as new
> headlines like so:  http://news.google.com/?output=rss or can anyone
> point
> me in the right direction for good online tutorials or books.

If you mean to just READ the XML, do this:
<?php
  $xml = file_get_contents("http://news.google.com/?output=rss";) or
die("Unable to read Google RSS at this time. Please try again
later.");
?>

If you need to get just the headlines, you could do:
<?php
  preg_match_all("/<title>([^<]*)<\\/title>/sU", $xml, $headlines);
  var_dump($headlines[1]);
?>

You could do similar work to get any of the content you wanted from
the XML.

Or you could use Google to search for "PHP RSS parser" and find
innumerable solutions.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux