How to create(replace) new xml node with as3?

i have text generated from an external xml file which i would like to be able to update from my flash file. in as2 ive done this with this sollution:


flagName = false;
nodeArray = myXML2.firstChild.childNodes;
  for (var i=0; i < nodeArray.length; ++i){
     if (nodeArray*.attributes.buttonName == buttonName) {
     flagName = true;
	 
myXML2.firstChild.childNodes*.lastChild.lastChild.removeNode();
myXML2.firstChild.childNodes*.firstChild.appendChild(myXML2.createTextNode(buttonName2));
 
     }
   }

when i try this in as3:


			var flagName:Boolean=false;
			for (var i=0; i<n; ++i) {

				if (node.childNodes*.childNodes[0].firstChild.nodeValue==namn_txt.text) {
					flagName=true;
					
					var nyXmlNod:XML=<message>{message_txt.text}</message>;
					trace(_xmlData.childNodes);
					node.childNodes*.childNodes[2].removeNode();
					//node.childNodes*.createElement("myText"); 
					node.childNodes*.childNodes[2].firstChild.appendChild(nyXmlNod);
					var urlRequest:URLRequest=new URLRequest("processXML.php");
					var urlParams:URLVariables=new URLVariables  ;
					urlParams.xmlVal=node;
					urlRequest.method=URLRequestMethod.POST;
					urlRequest.data=urlParams;
					var loader:URLLoader=new URLLoader  ;
					loader.load(urlRequest);
				}
			}

i get the following error message:
TypeError: Error #1034: Type Coercion failed: cannot convert XML@34ed6481 element <message> to flash.xml.XMLNode.at Main/SendButtonClickHandler()

how would i do this the best and easiest way?

thanks!