<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="horizontal"
    applicationComplete="applicationCompleteHandler(event)" viewSourceURL="srcview/index.html">
    
    <mx:XML id="externalXML" source="data.xml"/>
    
    <!--
    <mx:String id="internalXMLString">
        <![CDATA[
        <record letter="A" count="5">
            <childRecord letter="AA" count="2" />
            <childRecord letter="AB" count="3" />
        </record>
        <record letter="B" count="15">
            <childRecord letter="AA" count="7" />
            <childRecord letter="AB" count="8" />
        </record>
        <record letter="C" count="25">
            <childRecord letter="AA" count="15" />
            <childRecord letter="AB" count="10" />
        </record>
        <record letter="D" count="35">
            <childRecord letter="AA" count="22" />
            <childRecord letter="AB" count="13" />
        </record>
        ]]>
    </mx:String>
    -->
    
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;
            
            import org.axiis.data.DataSet;
            

            protected function applicationCompleteHandler(event:FlexEvent):void
            {
                var dataSet:DataSet = new DataSet();
                
                dataSet.processXmlString(externalXML.toString());
                textAreaIn.text = externalXML;
                var records:ArrayCollection = dataSet.data.object.records.record;
                
                //dataSet.processXmlString(internalXMLString);
                //textAreaIn.text = internalXMLString;
                //var records:ArrayCollection = dataSet.data.object.record;
                                
                var text:String = "";
                for each(var record:* in records)
                {
                    text += record.letter + " " + record.count + "\n";
                }
                textAreaOut.text = text;
            }
        ]]>
    </mx:Script>
    
    <mx:TextArea id="textAreaIn"
        width="100%"
        height="100%"/>
    
    <mx:TextArea id="textAreaOut"
        width="100%"
        height="100%"/>

</mx:Application>