"How To Get Attribute Value Of Root Element"?


P

pbd22

Hi.

Could somebody tell me how to get an attribute value from an
XML root element? for example, what would the javascript look
like to get the value "first" from the below root element? I thank
you.

<root id='first'>
<child id='1'>i am a child</child>
<child id='2'>i last a while</child>
</child>
 
Ad

Advertisements

M

Martin Honnen

pbd22 said:
Could somebody tell me how to get an attribute value from an
XML root element? for example, what would the javascript look
like to get the value "first" from the below root element? I thank
you.

<root id='first'>
<child id='1'>i am a child</child>
<child id='2'>i last a while</child>
</child>

If you have an XML DOM document then use
xmlDocument.documentElement.getAttribute('id')
 

Top