0 Replies Latest reply on Feb 8, 2007 2:52 PM by michaelrkruger

    trouble accessing elements of an XMLListCollection

    michaelrkruger
      Hi;

      I'm new to Flex and, for that matter, new to XML.

      I've set up an HTTPService accessing a model of a small SQL Server table "contacts". Also an XMLListCollection to hold the records retrieved (contactEditXLC). When I go straight to the model it does indeed return XML :
      -<contact>
      <company>ATCOM</company>
      <contact-name>Pam</contact-name>
      <phone>404/803-0996</phone>
      .
      .
      .
      <email-address/>

      I have other HTTPServices tied into this database and use datagrids (which allow assigning a dataprovider - the associated XMLListCollection) assigning fields to the dataField property of the DataGridColumn, ie :
      <mx:DataGridColumn headerText="Company" dataField="company"/>

      These all work.

      But, on this effort, I'm trying to assign XML data to TextInput controls in a VBox under an Accordian. The HTTPService, the XMLListCollection, and the call to the HTTPService.send() are all just like the others (the ones that work).

      I've tried setting up a separate Bindable variable to hold the "company" field and populating the TextInput.text with that. I've tried just accessing the XMLListCollection directly from the TextInput control in several manners:
      (ie: 1) text ="{contactEditXLC.company"}
      or 2) text="{contactEditXLC.contact.company}"
      or 3) text="{contactEditXLC.elements("contact").child("company")}"
      or 4) text="{contactEditXLC.elements("company")}"
      or 5) text="{contactEditXLC.child("company")}"

      All of which do not work.

      When I try accessing the fields by the data-field names as the documentation suggests you should (example 1) and 2) above), I get the following error upon compiling --- 1119: Access of possibly undefined property contact through a reference with static type mx.collections: XMLListCollection.

      I know this is probably a very stupid thing, but I've been working on it ALL day long and my eyes are crossed from reading all this documentation in which I can't seem to find anything on-point.

      Please help.