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

**URL:** <https://forum.kirupa.com/t/how-to-create-replace-new-xml-node-with-as3/281892>\
**Category:** Uncategorized\
**Created:** [February 14, 2009, 3:36pm UTC](https://forum.kirupa.com/t/how-to-create-replace-new-xml-node-with-as3/281892 "2009-02-14T15:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dojjjan](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dojjjan](https://forum.kirupa.com/u/Dojjjan)\
**Post date:** [February 14, 2009, 3:36pm UTC](https://forum.kirupa.com/t/how-to-create-replace-new-xml-node-with-as3/281892/1 "2009-02-14T15:36:05Z")

</div>

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:

```auto

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:

```auto

			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!
