1 Reply Latest reply on Jan 29, 2009 4:30 PM by EWN-CMI

    Showing data from a web service in a DataGrid

    taneojala
      My web service returns a complex XML document (ie. not a "flat" one). I'm able to consume the web service and create an XMLList and XMLListCollection based on the return value. If I make parts of the XML simple ("flat") I'm also able to bind values into a DataGrid row. However, I haven't succeeded in trying to display XML attribute values in this same DataGrid or values from elements in other XML branches of the XML.

      So, I have an XML structure
      <root>
      <element1>
      <se1>A</se1>
      <se2>B</se2>
      </element1>
      <element2>
      <se3 value="1"/>
      <se4 id="2">C</se4>
      </element2>
      </root>

      I can easily display (A,B) in a DataGrid, but how about (A, B, 1, 2, C) in a single row?

      I can find a bit similar examples in the internet, but for some reason I can't make it work. I'm using web services from ActionScript with a handler, I imported WSDL into the project, I don't have any MXML WebService components (would they make a difference?), I haven't specified E4X anywhere (should I ?). I can display single attribute values in a normal text field.

      Could someone please tell me the trick or point some directions to look at. Thanks.
        • 1. Re: Showing data from a web service in a DataGrid
          EWN-CMI Level 1
          I have thus far tried to stay away from XML but have looked at it a little bit. To me the structure of your XML file does not look like it would work straight into a dataGrid as you want. I would expect each row to be defined by elementX with columns of seX and seY. So I think you would see 2 rows (A,B) & (1,C) (It also looks to me like there is no "2" value from the code ie. (A,B,1,C) )

          I would try to build my XML file with all related items for a row to be listed between the elementX tags if I wasn't using database queries to populate the dataGrid.

          Good luck. I am a fan of the FlexDB library and highly recommend it to bypass the XML process.