I have the following xml
var xml:XML = <test>
<node id='1'/>
<node id='2'/>
<node id='3'/>
<node id='4'/>
<node id='5'/>
</test>;
var xmlist:XMLList = xml.children();
for each (var node:XML in xmlist)
{
node.@newAttribute = "1";
}
I'm looping through each node and adding an attribute. How can I do this without looping? I've tried this
xmlist.attributes().@newAttrib = "1";
but I'm getting the error "TypeError: Error #1089: Assignment to lists with more than one item is not supported."
As the error says, it's not supported. Since you cannot do this assignment to multiple elements, I don't see a way to do this without iterating over the xml.
For fun, I tried this and got the same error:
xml.node.@newAttribute=1It's just a slightly more terse version of: