Removing XML Nodes : delete « XML « Flash / Flex / ActionScript






Removing XML Nodes

 

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


        var movieList:XML = <movieList>
                                <listName>My favorite movies</listName>
                                <movie id="123">
                                    <title>Titus</title>
                                    <year>1999</year>
                                    <director>J T</director>
                                </movie>
                                <movie id="456">
                                    <title>Rushmore</title>
                                    <year>1998</year>
                                    <director>W A</director>
                                </movie>
                                <movie id="789">
                                    <title>Hall</title>
                                    <year>1977</year>
                                    <director>Woody Allen</director>
                                </movie>
                           </movieList>;
        delete movieList.movie[2];
        trace(movieList.movie);

    }
  }
}

        








Related examples in the same category

1.Removing Elements, Text Nodes, and Attributes
2.To delete all the items in the XMLList, use a for loop and iterate over the items in reverse order
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