0
votes

I am trying to populate a combobox in Flex 3 from XML returned via a web service.

Here is the code:

     <mx:WebService id="Services" 
    wsdl="http://10.10.15.4///WebService.asmx?wsdl"
    useProxy="false">
    <mx:operation   name="getAccounts"
                    showBusyCursor="true"
                    fault="showErrorDialog(event)">                         
    </mx:operation>
    </mx:WebService>

And the code for the combobox:

<mx:ComboBox id="accountPicker" labelField="Account" dataProvider="{Services.getAccounts.lastResult.Root.Node.Account}"/>

My XML that is returned looks like this:

<Root>
    <Node>
       <Account>Account1</Account>
    </Node>
   <Node>
       <Account>Account2</Account>
    </Node>
</Root>

What am i doing wrong here? currently the combobox is blank. If i remove the .Root.Node.Account from the dataProvider then it returns [Object Object].

Thanks

1

1 Answers

1
votes
  1. When dealing with e4x, the root is implicit so you just want xmlObject.Node.Account
  2. Node.Account gives you an XMLList of account nodes. These nodes don't have an "Account" property so labelField isn't going to work. If you just leave out the labelField, the combo box will call toString() on each element, which is automatically the inner text.

So what you want is:

<mx:ComboBox id="accountPicker" dataProvider="{Services.getAccounts.lastResult.Node.Account}" />