Please note that ExpatTech is close for the Christmas and New Year holidays. We will re-open on 2nd January 2024.

ExpatTech Techblog

Peter Todd 2010.09.23. 14:43

Flash Cookbook - XML - Practical XML

In Flash AS3, working with xml is really easy.

var xml:XML = <data></data>;

Tadaa, your xml is ready to fight.

But.

How to add an element? Good. But useless question, there is a method for this (xml.appendChild(object)).

So.

How to remove an element? And yes, YES, this is the good question. Let's say you have an xml with three chilren of the same name:

var xml:XML = <data><obj>1</obj><obj>2</obj><obj>3</obj></data>;

and you want to delete a child of the xml. Then comes the good old delete command

delete xml["obj"][0] //for deleting the first child

and so

delete xml["obj"] //to delete all the children with the name attribute "obj"