"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>
 
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')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top