PHP/XML Help Thanks (Fatal error: Call to a member function getAttribute() on...

Jake

New member
...a non-object)? This is my code (the error is occurring at the variable $cc_temp, cause its a fatal error it does not continue and most likely all the following lines are also incorrect as based off this line)

<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("weather.xml");

$cc_temp = $xmlDoc->getElementsByTagName('w:current')
->item(0)
->getAttribute('temperature');
?>


this is the weather.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<item>
<w:current temperature="29.3" />
</item>
</channel>
</rss>
 
Back
Top