c_pattle Posted July 2, 2010 Share Posted July 2, 2010 I have an XML document with this tag in it and I wanted to get the attribute values such as "fair", "33" and "18" <yweather:condition text="Fair" code="33" temp="18" date="Thu, 01 Jul 2010 11:50 pm BST"/> I have this code, however I get this error " Fatal error: Call to a member function getAttribute() on a non-object in /var/www/nmic/index.php". Can anyone help? $xdoc = new DomDocument; $xdoc->Load('http://weather.yahooapis.com/forecastrss?p=UKXX1270&u=c'); $candidatename = $xdoc->getElementsByTagName('yweather:condition')->item(0); $attribNode = $candidatename->getAttribute('text'); echo "Attribute Name is :".$attribNode->name; echo "<BR>Attribute Value is :".$attribNode->value; Quote Link to comment Share on other sites More sharing options...
gevik Posted July 2, 2010 Share Posted July 2, 2010 The XML feed you are getting from yahoo is actually a RSS feed. It would be much easier if you download an rss reader class from phpclasses.org and let the parser get the correct information for you instead of parsing it manually. I hope this helps Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.