A DataGrid can directly consume both XMLList and XMLListCollection.
Search the archives for a full discussion of DataGrid performance. Also these blog entries: http://blog.fastlanesw.com/?p=14 <http://blog.fastlanesw.com/?p=14> , http://blog.fastlanesw.com/?p=16. <http://blog.fastlanesw.com/?p=16.> I think it was Scott who brought this issue to the attention of the community first. This really only seems to be a major factor when you have many visible itemRenderers. I still use XML a lot. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sean Clark Hess Sent: Wednesday, July 02, 2008 6:19 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Inspecting data from HTTPService result to an ArrayCollection Tracy, can a datagrid read an xml object directly? (Like, an XMLList or XMLListCollection?) If so, why would manually converting it perform better than the original XML? Does it have something to do with the strong typing? Thanks ~sean On Wed, Jul 2, 2008 at 4:29 PM, Tracy Spratt <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: It is a rare case that you want to use mx:Model or the default resultFormat="object". You take the performance hit for the conversion, you have no control over the conversion process (your strings that look like numbers will get converted to numbers, willy nilly) and you wind up with dynamic objects, which have an access peformance penalty. I advise using resultFormat="e4x", a result handler function, and an instance variable to hold the xmlResult. The best performance, especially in a multi-renderer DataGrid, will be if you manually convert the XML node data ino an ArrayCollection of strongly typed value objects. Tracy ________________________________ From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Sean Clark Hess Sent: Wednesday, July 02, 2008 4:05 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: Re: [flexcoders] Inspecting data from HTTPService result to an ArrayCollection Ah, got it. The <mx:Model> tag converts everything to a flat object. So the minute you use it, you no longer have xml. It's still easy enough to loop through though. var result:Object = myData.getItemAt(0); for (var name:String in result) { trace(name + " :: " + result[name]); } should output apple :: 81768 orange :: 60310 banana :: 43357 On Wed, Jul 2, 2008 at 1:46 PM, Stephen More <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: Here is my output: DEBUG: 2 null [object Object] CHECK : false CHECK : false Here is all the code: <?xml version="1.0"?> <!-- charts/XMLFileToArrayCollectionDataProvider.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="100%" height="100%"> <mx:Script> import mx.utils.ArrayUtil; </mx:Script> <mx:Model id="results" source="../assets/data.xml"/> <mx:ArrayCollection id="myData" source="{ArrayUtil.toArray(results.result)}" /> <mx:Panel title="Line Chart"> <mx:LineChart id="chart" dataProvider="{myData}" showDataTips="true"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="banana" displayName="Banana"/> <mx:LineSeries yField="apple" displayName="Apple"/> <mx:LineSeries yField="orange" displayName="Orange"/> </mx:series> </mx:LineChart> <mx:Button id="iconButton" label="Button with Icon" labelPlacement="right" color="#993300" click="printMessage(event);"/> <mx:Script> <![CDATA[ import flash.events.Event; // Event handler function to print a message // describing the selected Button control. private function printMessage(event:Event):void { //message.text += event.target.label + " pressed" + "\n"; var myXML:XML; myXML = myData.getItemAt(0) as XML; trace( "DEBUG: " + myData.length + " " + myXML ); trace( myData.getItemAt(0) ); trace("CHECK : " + (myData.getItemAt(0) is XML)); trace("CHECK : " + (myData.getItemAt(0) is XMLList)); } ]]> </mx:Script> </mx:Panel> </mx:Application> On Wed, Jul 2, 2008 at 3:34 PM, Sean Clark Hess <[EMAIL PROTECTED] <mailto:seanhess%40gmail.com> > wrote: > What do you get when you trace myData.getItemAt(0)? That will return null > if it isn't an XML. You can do this too: > > trace("CHECK : " + (myData.getItemAt(0) is XML)); > > You can check to see if it is an XMLList too, but I thought looking at it, > it seemed like a flat xml. > > On Wed, Jul 2, 2008 at 1:32 PM, Stephen More <[EMAIL PROTECTED] <mailto:stephen.more%40gmail.com> > wrote: >> >> Thats what I was thinking but when I try: >> >> var myXML:XML; >> myXML = myData.getItemAt(0) as XML; >> trace( "DEBUG: " + myXML ); >> >> I get >> DEBUG: null >> >> On Wed, Jul 2, 2008 at 2:30 PM, Sean Clark Hess <[EMAIL PROTECTED] <mailto:seanhess%40gmail.com> > >> wrote: >> > Each row is an xml object... >> > >> > So, (myData.getItemAt(i) as XML).children() >> > >> > Then you could loop through the children and ask them for their name. >> > After >> > the as XML step you can do anything you can normally do with the XML >> > object >> > >> > On Wed, Jul 2, 2008 at 12:11 PM, Stephen More <[EMAIL PROTECTED] <mailto:stephen.more%40gmail.com> > >> > wrote: >> >> >> >> ( Example code taken from: >> >> http://livedocs.adobe.com/flex/201/html/charts_intro_108_12.html <http://livedocs.adobe.com/flex/201/html/charts_intro_108_12.html> ) >> >> Here is the dataset I am trying to work with: >> >> >> >> <data> >> >> <result month="Jan-04"> >> >> <apple>81768</apple> >> >> <orange>60310</orange> >> >> <banana>43357</banana> >> >> </result> >> >> <result month="Feb-04"> >> >> <apple>81156</apple> >> >> <orange>58883</orange> >> >> <banana>49280</banana> >> >> </result> >> >> </data> >> >> >> >> The flex code will look like this: >> >> <mx:HTTPService >> >> id="srv" >> >> url="../assets/data.xml" >> >> useProxy="false" >> >> result="myData=ArrayCollection(srv.lastResult.data.result)" >> >> /> >> >> >> >> How can I interrogate the ArrayCollection named myData so that it will >> >> return apple, orange, and banana ? >> >> I am not looking to get the numerical values, I want to get the xml >> >> name. >> >> >> >> -Thanks >> >> Steve More >> > >> > > >