Suppose we have the following piece of XML in a String field called “input”:
Now we want to set an attribute in <foo> with a certain id=5 :
var foo = new XML(input);
foo.@id = 5;
var result = foo.toXMLString()
As you can see from the syntax, you need to construct a special XML object before you can work with it like we did.
By the way, the result is :
Our friends over at Mozilla have compiled an extensive set of explanations and examples on this page. Great job Mozilla!
Until next time,