After googling for another couple of days and trying to find a namespace 
workaround.. which I never could get anything to work. Moreover, there's a 
chance the pre-fix could change depending on the server status (ie datas6 could 
be datas1 or datas2, etc.) I just took the route of stripping the namespace.  
Works great now.  Code is below:

private function resultHandler(event:ResultEvent):void
                                {
                                        var xmlResult:XMLList = 
XMLList(event.result);
                                        var xmlSource:String = 
xmlResult.toString();
                                        
                                        //Strip namespace
                                        xmlSource = 
xmlSource.replace(/<[^!?]?[^>]+?>/g, removeNamspaces);
                                        xmlResult = XMLList(xmlSource);
                                        
                                        //wrap XMLList in XMLListCollection
                                        var schedData:XMLListCollection = new 
XMLListCollection(xmlResult.children());                                  
                                        
                                        //Update Grid
                                        gc.source = schedData;
                                        gc.refresh();                           
        
                                }
                                
                        public function removeNamspaces(...rest):String
                                {
                                    rest[0] = 
rest[0].replace(/xmlns[^"]+\"[^"]+\"/g, "");
                                    var attrs:Array = 
rest[0].match(/\"[^"]*\"/g);
                                    rest[0] = rest[0].replace(/\"[^"]*\"/g, 
"%attribute value%");
                                    rest[0] = 
rest[0].replace(/(<\/?|\s)\w+\:/g, "$1");
                                    while (rest[0].indexOf("%attribute value%") 
> 0)
                                    {
                                        rest[0] = rest[0].replace("%attribute 
value%", attrs.shift());
                                    }
                                    return rest[0];
                                }

--- In [email protected], "Tracy Spratt" <tr...@...> wrote:
>
> You have a namespace issue.
> 
>  
> 
> You might be able to use the namespace in the dataField, like this:
> 
> dataField="datas6::Employee LastName", but I am not sure that will work.
> 
>  
> 
> But I would declare a namespace and use that.  I don't have any code handy,
> but search for namespace and you will find examples and more info.
> 
>  
> 
> Tracy Spratt,
> 
> Lariat Services, development services available
> 
>   _____  
> 
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Angelo Anolin
> Sent: Sunday, October 25, 2009 11:27 AM
> To: [email protected]
> Subject: [SPAM] Re: [flexcoders] Can't bind XMLListCollection to Datagrid
> 
>  
> 
>   
> 
> Could you try this one in your resultHandler....
> 
> 
> 
> private function resultHandler( event:ResultEven t):void
> {
> var xmlResult:XML = XML(event. result);
> var Employees:XMLListCollection = new XMLListCollection( xmlResult.table(
> ));
> trace(Employees) ;
> }
> 
> 
> 
>  
> 
>   _____  
> 
> From: jc_bad28 <jc_ba...@...>
> To: [email protected]
> Sent: Sunday, 25 October, 2009 13:30:24
> Subject: [flexcoders] Can't bind XMLListCollection to Datagrid
> 
>   
> 
> I changed my webservice call to return e4x but I can't get the
> XMLListCollection to bind to the datagrid.
> 
> Here is the pertinent AS code:
> 
> [Bindable]
> private var Employees:XMLListCo llection;
> 
> private function submit():void
> {
> EmployeeWS.GetAllEm ployees() ;
> }
> 
> private function resultHandler( event:ResultEven t):void
> { 
> var xmlResult:XMLList = new XMLList(event. result);
> var Employees:XMLListCo llection = new XMLListCollection( xmlResult.
> children( ));
> trace(Employees) ; 
> }
> 
> Here is how the trace returns the XMLListCollection data:
> 
> <datas6:Employee xmlns:datas6= "DM" xmlns:soapenv= "http://schemas.
> <http://schemas.xmlsoap.org/soap/envelope/>  xmlsoap.org/ soap/envelope/">
> <datas6:EmployeeID> 3</datas6: EmployeeID>
> <datas6:EmployeeLas tName>Badham< /datas6:Employee LastName>
> <datas6:EmployeeFir stName>John< /datas6:Employee FirstName>
> <datas6:EmployeeMid dleName>C. </datas6: EmployeeMiddleNa me>
> <datas6:PositionTit le>Data Manager</datas6: PositionTitle>
> </datas6:Employee>
> <datas6:Employee xmlns:datas6= "DM" xmlns:soapenv= "http://schemas.
> <http://schemas.xmlsoap.org/soap/envelope/>  xmlsoap.org/ soap/envelope/">
> <datas6:EmployeeID> 4</datas6: EmployeeID>
> <datas6:EmployeeLas tName>Bui< /datas6:Employee LastName>
> <datas6:EmployeeFir stName>Tai< /datas6:Employee FirstName>
> <datas6:EmployeeMid dleName>Tan< /datas6:Employee MiddleName>
> <datas6:PositionTit le>Inserter Operator</datas6: PositionTitle>
> </datas6:Employee>
> 
> Here is the datagrid code:
> 
> <mx:DataGrid id="myGrid" dataProvider= "{Employees} " height="272" y="10"
> width="603" x="167" borderStyle= "outset">
> <mx:columns>
> <mx:DataGridColumn headerText=" Last Name" dataField="Employee LastName" />
> <mx:DataGridColumn headerText=" First Name" dataField="Employee FirstName"
> />
> <mx:DataGridColumn headerText=" Position" dataField="Position Title"/>
> </mx:columns>
> </mx:DataGrid>
> 
> I've been spinning my wheels with this for 2 weeks now. It's probably
> something simple, but I can't figure it out after googling non-stop every
> damn day. Any help is greatly appreciated.
>


Reply via email to