Fetching a remote XML document : simplexml_load_string « XML « PHP

Fetching a remote XML document

$url = 'http://rss.news.yahoo.com/rss/oddlyenough';
$rss = simplexml_load_file($url);
print '<ul>';
foreach ($rss->channel->item as $item) {
   print '<li><a href="' .
         htmlentities($item->link) .
         '">' .
         htmlentities($item->title) .
print '</ul>';

Related examples in the same category

1.Accessing identically named elements
2.Adding attributes
3.Changing elements and attributes
4.Loop through children
5.Loading an XML document from a file
6.Parsing XML in a string
7.Parsing an XML Document with SimpleXML
9.Loading a remote XML document
10.Outputting XML
11.Using SimpleXML to extract data
12.Simple XML
13.Print XML element attributes
14.Printing sub-element contents
15.Saving an XML document to a file