XmlGrid Users Forum
2012-04-17 09:30:31
I want to change the values of attributes in an xml document. I want to do it in javascript. here is an example of my xml file:

__code__
<Objects> 
<User id="123" name="John Doe"> 
<Email Value="johndoe@mysite.com"/> 
</Objects>
__code__

Please let me know if you have any ideas...

Thanks. 

;3392;2012-04-17 09:30:31__s__
I want to change the values of attributes in an xml document. I want to do it in javascript. here is an example of my xml file:

__code__
<Objects> 
<User id="123" name="John Doe"> 
<Email Value="johndoe@mysite.com"/> 
</Objects>
__code__

Please let me know if you have any ideas...

Thanks. 

__s__~u=xml user~site=NULL__s__How to change xml attributes using Javascript?__s____m__2012-05-23 11:41:49__s__
In your sample code, if you want to change the name attribute of the User element, you can do this:

__code__
var c=document.getElementById(theElementId);
c.setAttribute("name","new value");
__code__

It is not very straightforward to change the Value attribute of the Email element in your sample, because it has no id. It is not very easy to get hold of this element. You have to add an id to the element that you want to manipulate in javascript.
__s__~u=Zac~site=NULL__s__ __s____m__

Best view with Google Chrome