cs1520: lab 7 ============= 1. php rss feed reader ---------------------- RSS (really simple syndication) is a standard format for publishing information that is updated regularly. RSS feeds are XML documents with the following basic structure: Each channel has one or more sections for each news article, blog post, etc. 1. Print an XML document ------------------------ Load an XML document from a URL and print its contents: load($url); echo $xmlDoc->saveXML(); ?> 2. Parse an RSS Feed -------------------- Write a php script that parses an RSS feed and displays the contents as an html page. For each item, show the title, link and description. First you will need to load a DOMDocument from a url. Then you will walk the DOM tree to extract the information you want. The documentation for DOM will be useful: http://php.net/manual/en/book.dom.php Here is some code to get started: My News Feed load($url); # example of how to get elements from "" $channel = $xmlDoc->getElementsByTagName('channel')->item(0); $channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue; $channel_link = $channel->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue; $channel_desc = $channel->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue; # output elements from "" echo("

" . $channel_title . "

"); echo("

" . $channel_desc . "



"); # get and output "" elements $items = $xmlDoc->getElementsByTagName('item'); # you do the rest: # create some html for each item ... ?>