XML text in a String into an actual XML object, whereas a cast would fail. : Bracket syntax « XML « Flash / Flex / ActionScript






XML text in a String into an actual XML object, whereas a cast would fail.

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var myXml:XML = XML("<root><party><time>Now</time><location>Here</location></party></root>");
        trace(myXml.party[0].time); //Now
    }
  }
}

        








Related examples in the same category

1.Build a property name and, consequently, an element name, dynamically
2.Bracket syntax is required for illegal property name
3.Adding Text Nodes to an XML Object
4.Use bracket notation, coupled with an integer, to access a particular element node
5.Use a variable's value as the element name to find:
6.Accessing Values with E4X: Using the Dot Operator to Access Elements