0 Replies Latest reply on Apr 26, 2007 7:06 AM by Mongolian Beef

    querying with e4x on complex xml

    Mongolian Beef Level 1
      I'm running into an issue where I don't know how to query an xml for use in a DataGridColumn. Below is an xml snippet (returned from a web service):
      quote:

      ....
      <ns3:PackWS xmlns:ns3="a" xmlns="b" xmlns:ns2="b" xmlns:ns1="c" xmlns:xsd="www.w3.org/2001/XMLSchema" xmlns:soap="schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
      <ns3:description xmlns="a"/>
      <ns3:id xsi:nil="true" xmlns="a"/>
      <ns3:name xmlns="a">Rivers Three</ns3:name>
      <ns3:value xmlns="a">2</ns3:value>
      </ns3:WS>
      <ns3:PackWS xmlns:ns3="a" xmlns="b" xmlns:ns2="b" xmlns:ns1="c" xmlns:xsd="www.w3.org/2001/XMLSchema" xmlns:soap="schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
      <ns3:description xmlns="a"/>
      <ns3:id xsi:nil="true" xmlns="a"/>
      <ns3:name xmlns="a">Barracuda</ns3:name>
      <ns3:value xmlns="a">1</ns3:value>
      </ns3:PackWS>
      ....



      Below is the datagrid code I trying to do:
      quote:


      public function createDataGrid():void {
      var bookResult:XMLList =
      bookSOAP.createBooks.lastResult.*:createBooksResult.*::books;

      var dg:DataGrid = new DataGrid();
      var dgc:DataGridColumn
      var aColumnsNew:Array = dg.columns;

      for (var i:int = 0; i < bookResult.length(); i++) {
      dgc = new DataGridColumn();
      dgc.headerText = bookResult .*::title;
      dgc.dataField = "name";
      aColumnsNew.push(dgc);

      }

      dg.columns = aColumnsNew;
      dg.width = 200;
      dg.dataProvider = bookResult[0].*::BookWS.*::packs*::PackWS;
      this.addChild(dg);
      }


      FYI, the dg.dataProvider = bookResult[0].*::BookWS.*::packs*::PackWS produces the XML fragment posted above. When trying to set the dataGridColumn's dataField property (bolded above) to the name node of this XML fragment, I get nothing. I'm not sure how to do this with AS/e4x. Any help on solving this would be appreciated. Thanks in advance!

      -los