Flash / Flex / ActionScript/XML/replace

Материал из Web эксперт
Перейти к: навигация, поиск

Use replace() to replace a single node with a new XML object.

   <source lang="java">

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).replace("genre", <category>Independent</category>);
       trace(movieList.movie.(@id == 123).toXMLString());
   }
 }

}

       </source>