Jump to content

get data from xml. please help


joequah1

Recommended Posts

Lots of people stumble over namespaced nodes with SimpleXML (e.g. your yweather:location).  The snippet below shows you how to get the location element and those attributes.

 

$location = $xml->channel->children('yweather', true)->location->attributes();
$city     = (string) $location->city;
$country  = (string) $location->country;
echo "Got $city in $country.";

 

More info:

 

http://php.net/simplexmlelement.children

http://php.net/simplexml.examples-basic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.