The toXMLString() method always return the full XML tag and all values contained within an element. : toString « XML « Flash / Flex / ActionScript






The toXMLString() method always return the full XML tag and all values contained within an element.

 


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

        var meal:XML = <meal>
                           <name>Dinner</name>
                           <course number="1">
                               <item>Salad</item>
                           </course>
                           <course number="2">
                               <item>Potatoes</item>
                               <item temperature="Medium Rare">Steak</item>
                           </course>
        
                       </meal>;
        
        trace(meal.name); // Displays: Dinner
        trace(meal.course[0]); // Displays: <course number="1">
        
        trace(meal.course[1].item[0].toXMLString()); // Displays: <item>Potatoes</items>
        trace(meal.course[1].item[1].toString()); // Displays: Steak
        trace(meal.course[1].item[1].@temperature.toXMLString()); 
        trace(meal..item.toString());
        
    }
  }
}

        








Related examples in the same category

1.If the XML object in question contains only a single node only the text value of the node will be returned
2.Printing Pretty
3.Setting the Number of Spaces per Indentation
4.Difference between toString and toXMLString
5.Converting an XML Element to a String
6.Converting an Attribute to a String