I'd like to delete some XML node with AS3. I've searched on google how to do that, but nothing seems to work.
Here a part of my XML :
<feed xmlns:xxxx="xxxx" xmlns:opensearch="xxx" xmlns="xxxx">
<title/>
<updated>date</updated>
<author>
<name>xxxxx</name>
</author>
<id>urn:tag:api@xxxx,date</id>
</feed>
Here my AS3 :
package {
import flash.text.TextField;
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
public class Hello extends Sprite
{
// Attributs
private var xmlLoader:URLLoader = new URLLoader();
// Constructor
public function Hello()
{
// Call XML Method
XMLcall();
}
// XMLcall Method
private function XMLcall():void
{
xmlLoader.load(new URLRequest("xxx"));
// When loaded, add event and launch XMLparser
xmlLoader.addEventListener(Event.COMPLETE, XMLcreate);
}
// XMLCreate Method
private function XMLcreate(e:Event):void
{
// Create var myXML which contains the xml
var myXML:XML = new XML(e.target.data);
// Delete node
delete myXML.author;
// Save as myxml.xml
var bytes:ByteArray = new ByteArray();
var fileRef:FileReference=new FileReference();
fileRef.save(myXML, "myxml.xml");
}
}
}
This code works but the node "Author" is still in my xml...
you have to consider the name space, replace this line:
with:
and it should work fine