> >> 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;
  }
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to