Posted by: edsyrett | 26 July 2008



It really took us way to long to figure out how to remove an XML node. Try using Microsoft’s XML DOM component – that implements appendChild() and removeChild() as part of the IXMLDomNode interface.

The XML class in ActionScript has the appendChild() method. So, we thought, where’s the removeChild() method?

It doesn’t work like that does it…instead of a proper DOM implementation, the XML implementation in ActionScript is more akin to a JavaScript object model. The livedocs page for the XML class here gives a clue – it says that the appendChild method “Appends the given child to the end of the XML object’s properties.”. The child is a property of the parent – just a normal bog-standard property, not a child node as in the MSXML implementation. Also, the signature takes an Object. Hardly typesafe, that.

Eventually we found out how to remove a child – it’s described here buried in with the documentation for the delete operator. Sorry Adobe, but ECMA standards or not, this is pretty disappointing.

Incidentally, here’s a handy way to generically remove an XML node (though I hesitate to call it a node when really it’s a property)….

public static function deleteNode(node:XML):void { if (node != null && node.parent() != null) { delete node.parent().children()[node.childIndex()]; } }




  1. Thanks! I’ve been looking for a way to delete XML nodes for a very long time.

  2. Golden tip man!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: