Looping over nodes as keys : XML data « Data Model « Flex






Looping over nodes as keys

Looping over nodes as keys
           

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundColor="white" creationComplete="tryme()">
    <mx:XML id="usersXML">
        <root>
            <users>
                <user id="1">
                    <firstname>A</firstname>
                    <lastname>A</lastname>
                </user>
                <user id="2">
                    <firstname>J</firstname>
                    <lastname>J</lastname>
                </user>
            </users>
        </root>
    </mx:XML>
    <mx:Script>
        
        [Bindable]
        public var infoString:String = "";
        public function tryme():void
        {
            for each(var node:XML in usersXML.users.user)
            {
              infoString = infoString + node.firstname;
               infoString = infoString + node.lastname;
            }
        }
      
    </mx:Script>
    <mx:TextArea text="{infoString}" width="250" height="100" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Displaying hierarchical XML dataDisplaying hierarchical XML data
2.Declare XML variableDeclare XML variable
3.Using the XML component to embed XML
4.Using the XML class to embed XML
5.Using XML class's static propertiesUsing XML class's static properties
6.Using the source property to filter and bind to XML data
7.Populating XML by binding external dataPopulating XML by binding external data
8.XML used for E4X examples
9.Looping over an XML structure using its indexLooping over an XML structure using its index
10.Looping over an XML fragmentLooping over an XML fragment
11.Adding a child XML node at the endAdding a child XML node at the end
12.For each variable from xml dataFor each variable from xml data
13.Use XMListCollection removeItemAt() method to remove the itemUse XMListCollection removeItemAt() method to remove the item
14.Load Date range data from XMLLoad Date range data from XML
15.Use URLLoader to load XML data from server
16.Construct XML data from returning result from service call
17.Load XML data from server with URLLoader
18.Use reference XML data element and attributeUse reference XML data element and attribute
19.An data model with binding destinations in curly bracesAn <mx:XML> data model with binding destinations in curly braces
20.Define data Model structure with xml
21.Reference attribute value in XML modelReference attribute value in XML model
22.Set the value of the format attribute of the tag to xml
23.Model with a simple XML structure
24.XML data
25.Get value from XML data by using namespaceGet value from XML data by using namespace
26.Get XML from PhpGet XML from Php
27.Navigate an XML Document in E4X
28.Encode an ActionScript Data Object as XML
29.Populate a Component with Complex XML Data
30.Binding XML to ListBinding XML to List
31.Binding XML data to LabelBinding XML data to Label
32.External XML File
33.Bind to Properties on XML by Using E4XBind to Properties on XML by Using E4X
34.Use XPath to get data
35.Use Regular Expressions in E4X Queries
36.Inserting a node after an existing one
37.Using || (or) notationUsing || (or) notation
38.Reference Repeated ComponentsReference Repeated Components
39.Referene Repeated Child ComponentsReferene Repeated Child Components
40.Reference Nested ComponentsReference Nested Components
41.Adding and removing leaf nodes at run timeAdding and removing leaf nodes at run time
42.namespace variablenamespace variable