I'm trying to update a value in a subnode of an XML structure. New value should come from an Input TextField whose instance name is the same of the value of the attribute of the node I should update.
For example, when focusing out textfield called "label10", I should edit the node:
<label id="label10">
<eng>Description</eng>
<de>DE Description</de>
</label>
...and that's ok, I achieved it using this callback function:
private function onFocusOut (evt:FocusEvent):void {
var nodeToModify:XML = xmlFillData.label.(@id==evt.target.name)[0];
trace ("nodeToModify is " +nodeToModify );
}
Now my problem is I wish to replace the content of the subnode eng or de, depending on a variable defined in a static class called VarHolder, but I'm not able to do it.
I've tried to use this line inside the callback function:
nodeToModify.replace (VarHolder.activeLang , evt.target.text);
but then if I trace nodeToModify, this is the result ( tag disappeared)
<label id="label10">
rrr
<de>DE Description</de>
Any help?
EDIT (and solved): trying to implement @jens answer. This is how I did it
nodeToModify.replace (VarHolder.activeLang, new XML("<" + VarHolder.activeLang + ">" + evt.target.text + "</" + VarHolder.activeLang + ">"));