/* I start with this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report> /* I want this result (change the value of node 'prop5'): */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>false</prop5> </Report> /* I tried this: */ var reportXML:XML = <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report>; var myArray:Array = [{xmlNodeName: 'prop5', value: false}]; for each (var item:Object in myArray) { report.xml[item.xmlNodeName] = item.value.toString(); } /* But this just adds a new node, resulting in this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> <prop5>false</prop5> </Report>;
/* I start with this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report> /*
Share
This seems to be doing exactly what you want. It’s just your code with some typos fixed.