Removing Elements, Text Nodes, and Attributes : delete « XML « Flash / Flex / ActionScript






Removing Elements, Text Nodes, and Attributes

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var example:XML = <example>
                            <fruit color="Red">Apple</fruit>
                            <vegetable color="Green">Broccoli</vegetable>
                            <dairy color="White">Milk</dairy>
                          </example>;
                          
        delete example.fruit.@color;
        
        delete example.dairy;
        
        delete example.vegetable.text(  )[0];
        
        trace( example );


    }
  }
}

        








Related examples in the same category

1.To delete all the items in the XMLList, use a for loop and iterate over the items in reverse order
2.Removing XML Nodes
3.The delete operator works for other types of nodes as well, such as attributes.
4.Remove all attributes from the movie Tron.
5.Delete all attributes of an element