title: Replace xml subnode value in AS3
body: <p>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.</p>
  
  <p>For example, when focusing out textfield called "label10", I should edit the node:</p>
  
  <pre><code>&lt;label id="label10"&gt;
      &lt;eng&gt;Description&lt;/eng&gt;
      &lt;de&gt;DE Description&lt;/de&gt;
  &lt;/label&gt;
  </code></pre>
  
  <p>...and that's ok, I achieved it using this callback function:</p>
  
  <pre><code>private function onFocusOut (evt:FocusEvent):void {
          var nodeToModify:XML = xmlFillData.label.(@id==evt.target.name)[0];
          trace ("nodeToModify is " +nodeToModify );
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>I've tried to use this line inside the callback function:</p>
  
  <pre><code> nodeToModify.replace (VarHolder.activeLang , evt.target.text);
  </code></pre>
  
  <p>but then if I trace nodeToModify, this is the result ( tag disappeared)</p>
  
  <pre><code>&lt;label id="label10"&gt;
  rrr
  &lt;de&gt;DE Description&lt;/de&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any help?</p>
  
  <hr>
  
  <p>EDIT (and solved): trying to implement @jens answer.
  This is how I did it</p>
  
  <pre><code> nodeToModify.replace (VarHolder.activeLang,  new XML("&lt;" + VarHolder.activeLang + "&gt;" +  evt.target.text + "&lt;/" + VarHolder.activeLang + "&gt;"));
  </code></pre>