Quantcast
Channel: XML RSS Feed Parse PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 3

XML RSS Feed Parse PHP

$
0
0

With an XML feed like so:

<w:current temperature="22.2" dewPoint="12.9" humidity="56" windSpeed="5.6" windGusts="9.3" windDirection="ESE" pressure="1017.8" rain="0.0" />

and

<w:forecast day="Thursday" description="Mostly Sunny. Warm." min="17" max="29" icon="2" iconUri="http://www.weather.com.au/images/icons/2.gif" iconAlt="Mostly Sunny" />

How do I parse it in PHP using the dom?

$doc = new DOMDocument();$doc->load('http://rss.weather.com.au/sa/adelaide');$arrFeeds = array();foreach ($doc->getElementsByTagName('item') as $node) {    $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,'description' => $node->getElementsByTagName('w')->item(0)->nodeValue,        );    array_push($arrFeeds, $itemRSS);}

Returns error :Notice: Trying to get property of non-object in /var/www/index.php on line 123


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images