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__
17,CSS;100,General;15,javascript;16,javascript CSS;8,XML C/C++;10,XML converter;12,XML data warehouse;13,XML database;4,XML editor;1,XML general;11,XML HTML;7,XML java;6,XML javascript;5,XML parser;9,XML PHP;2,XML schema;3,XML syntax;14,XPath;