3 Replies Latest reply on Mar 13, 2009 5:04 PM by Newsgroup_User

    Retrieving XML  data and making it available in a DataGrid

      I need to retrieve the xml data from the file below (mycontactdata.xml) which will be in my assets folder in my Project directory. I only need to retrieve the xml data for the 2nd node (CONTACTLIST) which then needs to be displayed in a DataGrid. The DataGrid will be in a separate mxml file whereas the retrieving of the xml data will be done in the main Application mxml file.

      Any ideas? Thanks

      <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      - <DATATABLES>
      - <DATATABLE ID="SYSTEM">
      - <ROW ID="0">
      <COLUMN ID="#SCENE_ID" VALUE="1" />
      </ROW>
      </DATATABLE>
      - <DATATABLE ID="CONTACTLIST">
      - <ROW ID="0">
      <COLUMN ID="CON_ID" VALUE="1+7Q+149" />
      <COLUMN ID="First Name" VALUE="PATRICIA" />
      <COLUMN ID="Last Name" VALUE="DEROCHIE" />
      <COLUMN ID="Account Name" VALUE="COUNTY OF BRUCE GENERAL HOSP." />
      <COLUMN ID="Contact Type" VALUE="Chief of Pharmacy" />
      <COLUMN ID="Primary Specialty" VALUE="Not Applicable" />
      <COLUMN ID="Main Phone" VALUE="15198811220" />
      </ROW>
      - <ROW ID="1">
      <COLUMN ID="CON_ID" VALUE="1+51+2249" />
      <COLUMN ID="First Name" VALUE="DUNCAN C M" />
      <COLUMN ID="Last Name" VALUE="GRAHAM" />
      <COLUMN ID="Account Name" VALUE="" />
      <COLUMN ID="Contact Type" VALUE="Physician" />
      <COLUMN ID="Primary Specialty" VALUE="General Surgery" />
      <COLUMN ID="Main Phone" VALUE="5198812880" />
      </ROW>
      - <ROW ID="2">
      <COLUMN ID="CON_ID" VALUE="1+4Z+3962" />
      <COLUMN ID="First Name" VALUE="HENDRINA SUSAN" />
      <COLUMN ID="Last Name" VALUE="MCARTHUR" />
      <COLUMN ID="Account Name" VALUE="" />
      <COLUMN ID="Contact Type" VALUE="Physician" />
      <COLUMN ID="Primary Specialty" VALUE="General Practice" />
      <COLUMN ID="Main Phone" VALUE="5198814640" />
      </ROW>
      - <ROW ID="3">
      <COLUMN ID="CON_ID" VALUE="1+51+3323" />
      <COLUMN ID="First Name" VALUE="PAUL EDWARD" />
      <COLUMN ID="Last Name" VALUE="MCARTHUR" />
      <COLUMN ID="Account Name" VALUE="" />
      <COLUMN ID="Contact Type" VALUE="Physician" />
      <COLUMN ID="Primary Specialty" VALUE="General Practice" />
      <COLUMN ID="Main Phone" VALUE="5198814640" />
      </ROW>
      </DATATABLE>
      - <DATATABLE ID="ACTIVE_LAYOUTS" NAME="ACTIVE_LAYOUTS" TYPE="ARRAY">
      - <ROW ID="1" NAME="Row">
      <COLUMN ID="TYPE" NAME="TYPE" VALUE="HEADOFFICE" />
      </ROW>
      </DATATABLE>
      </DATATABLES>
        • 1. Re: Retrieving XML  data and making it available in a DataGrid
          Gregory Lafrance Level 6
          This works, although I'm extremely surprised there's no way to do it with e4x syntax:
          • 2. Re: Retrieving XML  data and making it available in a DataGrid
            Thanks, Greg. This is good. I will see if I can put the DataGrid into a popup window that I am going to use.
            • 3. Re: Retrieving XML  data and making it available in a DataGrid
              Level 7

              "hkpadobe" <webforumsuser@macromedia.com> wrote in message
              news:gpdvf2$br5$1@forums.macromedia.com...
              >I need to retrieve the xml data from the file below (mycontactdata.xml)
              >which
              > will be in my assets folder in my Project directory. I only need to
              > retrieve
              > the xml data for the 2nd node (CONTACTLIST) which then needs to be
              > displayed in
              > a DataGrid. The DataGrid will be in a separate mxml file whereas the
              > retrieving
              > of the xml data will be done in the main Application mxml file.
              >
              > Any ideas? Thanks
              >
              > <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
              > - <DATATABLES>
              > - <DATATABLE ID="SYSTEM">
              > - <ROW ID="0">
              > <COLUMN ID="#SCENE_ID" VALUE="1" />
              > </ROW>
              > </DATATABLE>
              > - <DATATABLE ID="CONTACTLIST">
              > - <ROW ID="0">
              > <COLUMN ID="CON_ID" VALUE="1+7Q+149" />
              > <COLUMN ID="First Name" VALUE="PATRICIA" />
              > <COLUMN ID="Last Name" VALUE="DEROCHIE" />
              > <COLUMN ID="Account Name" VALUE="COUNTY OF BRUCE GENERAL HOSP." />
              > <COLUMN ID="Contact Type" VALUE="Chief of Pharmacy" />
              > <COLUMN ID="Primary Specialty" VALUE="Not Applicable" />
              > <COLUMN ID="Main Phone" VALUE="15198811220" />
              > </ROW>
              > - <ROW ID="1">
              > <COLUMN ID="CON_ID" VALUE="1+51+2249" />
              > <COLUMN ID="First Name" VALUE="DUNCAN C M" />
              > <COLUMN ID="Last Name" VALUE="GRAHAM" />
              > <COLUMN ID="Account Name" VALUE="" />
              > <COLUMN ID="Contact Type" VALUE="Physician" />
              > <COLUMN ID="Primary Specialty" VALUE="General Surgery" />
              > <COLUMN ID="Main Phone" VALUE="5198812880" />
              > </ROW>
              > - <ROW ID="2">
              > <COLUMN ID="CON_ID" VALUE="1+4Z+3962" />
              > <COLUMN ID="First Name" VALUE="HENDRINA SUSAN" />
              > <COLUMN ID="Last Name" VALUE="MCARTHUR" />
              > <COLUMN ID="Account Name" VALUE="" />
              > <COLUMN ID="Contact Type" VALUE="Physician" />
              > <COLUMN ID="Primary Specialty" VALUE="General Practice" />
              > <COLUMN ID="Main Phone" VALUE="5198814640" />
              > </ROW>
              > - <ROW ID="3">
              > <COLUMN ID="CON_ID" VALUE="1+51+3323" />
              > <COLUMN ID="First Name" VALUE="PAUL EDWARD" />
              > <COLUMN ID="Last Name" VALUE="MCARTHUR" />
              > <COLUMN ID="Account Name" VALUE="" />
              > <COLUMN ID="Contact Type" VALUE="Physician" />
              > <COLUMN ID="Primary Specialty" VALUE="General Practice" />
              > <COLUMN ID="Main Phone" VALUE="5198814640" />
              > </ROW>
              > </DATATABLE>
              > - <DATATABLE ID="ACTIVE_LAYOUTS" NAME="ACTIVE_LAYOUTS" TYPE="ARRAY">
              > - <ROW ID="1" NAME="Row">
              > <COLUMN ID="TYPE" NAME="TYPE" VALUE="HEADOFFICE" />
              > </ROW>
              > </DATATABLE>
              > </DATATABLES>
              >

              Try something like:

              myDataProvider:XMLListCollection =
              dataTablesXML.(attribute('ID')=='CONTACTLIST').child('ROW');

              You may need to refine it a bit to get it to actually work, but this should
              point you in the right direction.

              The problem from there is that all of your objects inside the row then have
              exactly the same name and the attribute you're looking for is also the same
              (ID). So you'll have to use a labelFunction from there and look and see
              what the ID _is_ to decide which column to put the data in.

              HTH;

              Amy


              1 person found this helpful