Displaying hierarchical XML data : XML data « Data Model « Flex






Displaying hierarchical XML data

Displaying hierarchical XML data
     


<?xml version="1.0"?>
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.collections.HierarchicalData;
        import mx.collections.XMLListCollection;
      
    </mx:Script>
    <mx:XMLList id="myHierarchicalDataXML">
        <Column1 Column1="Southwest">
            <Column1 Column1="Arizona">
                <Column2 Column2="Barbara Jennings" Value1="38865" Value2="40000" />
                <Column2 Column2="Dana Binn" Value1="29885" Value2="30000" />
            </Column1>
            <Column1 Column1="Central California">
                <Column2 Column2="Joe Smith" Value1="29134" Value2="30000" />
            </Column1>
            <Column1 Column1="Nevada">
                <Column2 Column2="Bethany Pittman" Value1="52888" Value2="45000" />
            </Column1>
            <Column1 Column1="Northern California">
                <Column2 Column2="Lauren Ipsum" Value1="38805" Value2="40000" />
                <Column2 Column2="T.R. Smith" Value1="55498" Value2="40000" />
            </Column1>
            <Column1 Column1="Southern California">
                <Column2 Column2="Alice Treu" Value1="44985" Value2="45000" />
                <Column2 Column2="Jane Grove" Value1="44913" Value2="45000" />
            </Column1>
        </Column1>
    </mx:XMLList>
    <mx:AdvancedDataGrid width="100%" height="100%"
        dataProvider="{new HierarchicalData(myHierarchicalDataXML)}">
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="@Column1"
                headerText="Column1" />
            <mx:AdvancedDataGridColumn dataField="@Column2"
                headerText="Column 2" />
            <mx:AdvancedDataGridColumn dataField="@Value1"
                headerText="Value1" />
            <mx:AdvancedDataGridColumn dataField="@Value2"
                headerText="Value2" />
        </mx:columns>
    </mx:AdvancedDataGrid>
</mx:Application>

   
    
    
    
    
  








Related examples in the same category

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