php - reading external XML file -
i need use external xml file, i've tried different methods read file can't reach want.
i used domdocument
simplexml_load_file
<? $xml = simplexml_load_file("http://www.isecur1ty.org/internetthreat/threatlevel.xml"); echo $xml->getname() . "<br />"; foreach($xml->children() $child) { echo $child->getname() . ": " . $child . "<br />"; } ?>
but can't working me!!
here xml file:
<is-internetthreat> <level> <current>2</current> <previous>2</previous> <status>same</status> <date>09-06-2012</date> </level> <version>2.5</version> </is-internetthreat>
as can see, there multi-levels. need values of each attribute (mainly under "level"), getting version ok.
can tell me how this?
thanks.
access them this:
<?php $xml = simplexml_load_file("http://www.isecur1ty.org/internetthreat/threatlevel.xml"); echo $xml->level->date; ?>
Comments
Post a Comment