How to get the value of an attribute from XML file in PHP?
Posted
by
Matt
on Stack Overflow
See other posts from Stack Overflow
or by Matt
Published on 2009-08-10T19:40:35Z
Indexed on
2011/02/28
7:25 UTC
Read the original article
Hit count: 110
Hi,
Sorry if this seems like an easy question, but I've started pulling hair out on this...
I have a XML file which looks like this...
<VAR VarNum="90">
<option>1</option>
</VAR>
I'm trying to get the VarNum.
So far I've been successful using the follow code to get the other information:
$xml=simplexml_load_file($file);
$option=$xml->option;
I just can't get VarNum (the attribute value I think?)
Thanks!
© Stack Overflow or respective owner