Loading Multiple XML feeds - PHP

sunnytollyt

New Member
I have a php file setup to pull through ONE XML data feed, What I would like to do is load up to 4 feeds into it and if possible make it select a random item too. Then parse that into an jQuery News Ticker.My current PHP is as follows...\[code\]<?php$feed = new DOMDocument();$feed->load('/feed');$json = array();$json['title'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('title')->item(0)->firstChild->nodeValue;$json['description'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('description')->item(0)->firstChild->nodeValue;$json['link'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('link')->item(0)->firstChild->nodeValue;$items = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('item');$json['item'] = array();$i = 0;foreach($items as $item) { $title = $item->getElementsByTagName('title')->item(0)->firstChild->nodeValue; $description = $item->getElementsByTagName('description')->item(0)->firstChild->nodeValue; $pubDate = $item->getElementsByTagName('pubDate')->item(0)->firstChild->nodeValue; $guid = $item->getElementsByTagName('guid')->item(0)->firstChild->nodeValue; $json['item'][$i++]['title'] = $title; $json['item'][$i++]['description'] = $description; $json['item'][$i++]['pubdate'] = $pubDate; $json['item'][$i++]['guid'] = $guid; echo '<li class="news-item"><a href="http://stackoverflow.com/questions/11016846/#">'.$title.'</a></li>';}//echo json_encode($json);?>\[/code\]How can I modify this to load more than one feed into the file?Thanks in advance
 
Back
Top