5 Replies Latest reply on Jan 6, 2007 2:51 AM by newman_

    large external XML file

    newman_ Level 1
      Hi!
      I have XML file which is large (about 8MB). I imported it and put data from XML into DataGrid. It works...
      ....BUT when I try to manipulate on data (show details, find something etc.) each Query takes 5-8 seconds.

      Could you give me some TIPs or solutions how to speed up data manipulations on large XML file???
      Thanks!

      newman
        • 1. Re: large external XML file
          FlightGuy Level 1
          Hard to tell without seeing more detail of what you're doing. Try putting the data relevant to the grid into an ArrayCollection of objects and then convert back to XML when you're ready to send it back to the server.

          Tim
          • 2. Re: large external XML file
            newman_ Level 1
            I'm just using DataGrid to show data from external XML. I imported XML file and then put it into DataGrid. I didn't convert data from XML to ArrayCollection.
            I didn't send it back to the server.

            Few main lines from my code:
            // var
            [Bindable]
            public var XMLmyData : XML;
            // load XML
            xmlFileMyData.send();
            // handle after load
            XMLmyData = XML(xmlFileMyData.lastResult);
            // in DataGrid
            dataProvider="{XMLmyData}"

            • 3. Re: large external XML file
              ntsiii Level 3
              It won't do anything for speed, but don't use lastResult in a handler function. INstead, pass the event object to the handler: result="onResult(event)", and in the handler:
              private function onResult(event:ResultEvent):void
              XMLmyData = XML(event.result);

              Also, how are you manipulating the data? Are you using e4x expressions?

              Tracy
              • 4. large external XML file
                newman_ Level 1
                Here is my code with more details. I deleted not important parts.
                It's not full original code. I'm using e4x expressions.

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="{applicationStart()}" >
                <mx:HTTPService id="xmlFileMyData" url="test.xml" resultFormat="e4x" result="handleLoad()" fault="handleFail()" useProxy="false" showBusyCursor="true"/>

                <mx:Script>
                <![CDATA[

                import mx.messaging.management.Attribute;
                import flash.utils.*;
                import mx.collections.ArrayCollection;
                import mx.controls.dataGridClasses.DataGridColumn;
                import mx.controls.TextArea;

                [Bindable]
                public var XMLmyData:XML;
                [Bindable]
                private var ExpDays:String;
                [Bindable]
                private var SumServ:String;
                [Bindable]
                private var wService:String;

                [Bindable]
                private var myProp: String;
                private var loadCount:Number = 0;
                private var initDG:Array;
                private var k:Number;
                [Bindable]
                private var ExplorationsL:String;

                private function applicationStart():void {
                runApp();
                }
                private function runApp():void {
                loadXML();
                }
                private function loadXML():void {
                xmlFileMyData.send();
                }
                private function handleLoad():void {

                XMLmyData = XML(xmlFileMyData.lastResult);

                }
                private function handleFail():void {
                // failed
                }

                ]]>
                </mx:Script>

                <mx:Panel name="mainpanel" width="800" height="450" paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" layout="absolute" x="10" y="75" title="Analizy" alpha="1.0">
                <mx:DataGrid selectedIndex="0" tabChildren="true" x="20" y="20" id="dgData" width="740" height="250" dataProvider="{XMLmyData.nodes.singlenode}">
                <mx:columns>
                <mx:DataGridColumn width="130" headerText="header" dataField="" >
                <mx:itemRenderer>
                <mx:Component>
                <mx:VBox clipContent="false">
                <mx:Text text="{data.myid[data.myid.length()-1].toString()}"/>
                </mx:VBox>
                </mx:Component>
                </mx:itemRenderer>
                </mx:DataGridColumn>
                </mx:columns>
                </mx:DataGrid>
                </mx:Panel>
                </mx:Application>

                I'm using handlers because in original code I import few XML files.
                My XML structure looks like:
                --main
                ----node
                ------singlenode
                --------myid
                --------myid

                I created names special for this post.

                • 5. large external XML file
                  newman_ Level 1
                  Tracy: why you suggest NOT to use lastResult in a handler function ??
                  I actually test it (I added onResult(oEvent:ResultEvent)) and still getItemAt in my itemRenderer (in DataGrid) doesn't show data.
                  Maybe I make some syntax error...?
                  {data.myid.getItemAt(0).toString()}
                  I tested this too:
                  {data.getItemAt(0).myid.toString()}
                  ...and nothing, no data in DataGrid :/