Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > "How To Get Attribute Value Of Root Element"?

Reply
Thread Tools

"How To Get Attribute Value Of Root Element"?

 
 
pbd22
Guest
Posts: n/a
 
      07-03-2007
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>

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-03-2007
pbd22 wrote:

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

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Change the value of an attribute according to the value of another attribute patrizio.trinchini@googlemail.com XML 8 08-22-2006 02:53 PM
wrapping long attribute value (line-continuation for attribute value) lophiomys@gmx.at XML 1 08-02-2006 01:18 PM
Get root attribute values question 2 GIMME XML 8 01-10-2005 05:24 AM
Get root attribute values GIMME XML 3 04-12-2004 02:38 AM



Advertisments