Use the dot operator (.) on the XML instance and add the element : XML Element « XML « Flash / Flex / ActionScript






Use the dot operator (.) on the XML instance and add the element

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:XML = <example />;
        // Create a new XML node named newElement and add it to the example instance
        example.newElement = <newElement />;
        trace( example );
    }
  }
}

        








Related examples in the same category

1.Access XML elements by index
2.Change the element's value
3.Assign XML element value
4.Accessing Text Nodes
5.Create a new element by creating a property on the XML instance and assigning it a value