Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change XML attribute using Javascript?

Status
Not open for further replies.

focusdev

Programmer
May 9, 2007
18
US
I need to change an attribute located in my xml using javascript but can not seem to find how to do it.

Code:
<html>
...
<xml id=daxml>
  <group>
     <item>
       <desc listing='123'>
     </item>
  </group>
</xml>

In the above sample, I need to change listing to 234.

Any ideas?
 
Nevermind, I think I figured it out.
Code:
var myXML = document.getElementById('daxml');
var desc  = myXML.selectSingleNode("//group/item/desc");
desc.setAttribute('listing','234');
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top