I've actually never used XMLListCollection so I'm giving it a shot.  
It seems to be giving me some problems.  I'm returning a length of 0.
Is this correct or did I miss something.  All the examples in the 
Help show it as MXML not ActionScript.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute" creationComplete="myXML.send()">
<mx:Script>
        <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.rpc.events.ResultEvent;
                //
                [Bindable]
                public var projectHolder:XMLListCollection;
                //
                public function extractProjects
(event:ResultEvent):void {
                        var xmlResult:XML = XML(event.result);
                        trace(xmlResult.toXMLString());
                        projectHolder = new XMLListCollection
(xmlResult.projects.project);
                        trace(projectHolder.length);
                }
        ]]>
</mx:Script>

<mx:HTTPService id="myXML" url="http://getProjectXML.asp"; 
resultFormat="xml" result="extractProjects(event)"/>

</mx:Application>






--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> 
wrote:
>
> Oops yeah I misread that conditional + loop code.
> 
>  
> 
> But you ARE mangling your xml.  The default resultFormat of 
HTTPService
> is "object", which causes flex to convert your xml into a nested 
object
> structure.  Such a structure is hard to debug and is less flexible 
than
> xml.
> 
>  
> 
> I advise using resultFormat="xml".  Type projectArray as
> XMLListCollection. Then in the result handler do:
> 
> var xmlResult:XML = XML(event.result);
> 
> trace(xmlResult.toXMLString());  //to verify your structure
> 
> projectArray = new XMLListCOllection(xmlResult.projects.project);
> 
> trace(projectArray.length);  //to verify your list
> 
>  
> 
> Now, the dg.selectedItem will hold a <project> node.
> 
>  
> 
> You could bind directly to the selectedItem, but for easier
> troubleshooting, I would declare a var(XMLList) to hold the detail
> dataProvider(s), and assign them in a change handler of the dg:
> 
> var xmlItem:XML = XML(event.target.selectedItem);
> 
> trace(xmlItem.toXMLString()); //to verify your item structure
> 
> _xlResources = xmlItem.resources.item
> 
>  
> 
> Bind the repeater to _xlResources.
> 
>  
> 
> Tracy
> 
>  

Reply via email to