Re: Re: Need help... getting information from external xml document

From: Date: Thu, 23 Sep 2004 15:01:57 +0000
Subject: Re: Re: Need help... getting information from external xml document
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-197695@lists.php.net to get a copy of this message
> >> I am new to php and xml and would like to know how I can set a > >> variable (i.e $terror_threat_level) equal to the value of > >> Threat_Advisory's Condition in the following that is available at > >> http://www.dhs.gov/dhspublic/getAdvisoryCondition ... > >> > >> <?xml version="1.0" encoding="UTF-8" ?> > >> <THREAT_ADVISORY CONDITION="ELEVATED" /> if you are using php 5 you could try this: $file = 'http://www.dhs.gov/dhspublic/getAdvisoryCondition'; $xml = simplexml_load_file($file); print findAttribute($xml,'CONDITION'); function findAttribute($object, $attribute) { foreach($object->attributes() as $a => $b) { if ($a == $attribute) { $return = $b; } } if($return) { return $return; } }

« previous php.general (#197695) next »