Replacing Values in XML Nodes : Child : XML Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » XML » Child »

 

Replacing Values in 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>;
        
        movieList.movie.(@id == 123).setChildren(null);
        trace(movieList.movie.(@id == 222).toXMLString());
        
        movieList.movie.(@id == 123).setChildren(<title>Sleep</title> +
                                                 <year>2006</year> +
                                                 <director>M G</director> +
                                                 <genre>Romance</genre>);
        trace(movieList.movie.(@id == 123).toXMLString());

    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo XML
» Child