2 Replies Latest reply on Mar 22, 2007 1:03 AM by ::E1::

    Datagrid <- XML attributes and text

      Please help with this. I am trying to load XML data into datagrid. If I use only text nodes or attributes, I can get it work. But if I have mixed XML content, I cannot get data I need.
      All examples I've found so far use or just attributes or just nodes. No mixed content.

      <data id="1">
      <name nickname="jay"> JACK</name>

      How to show all data in datagrid using HTTP service in FlexBuilder?

      <mx:DataGridColumn headerText="PROJEKT" dataField="@id"/>
      <mx:DataGridColumn headerText="ID" dataField="NAME"/>
      <mx:DataGridColumn headerText="PONUDA" dataField="@nickame"/>

      This example shows just first two of them. I cannot get nickname shown nut even using labelFunction. Also, I have more complexed XML than this.

      Please help & thank you.

        • 1. Re: Datagrid &lt;- XML attributes and text
          ntsiii Level 3
          That code has several typos.

          Check your spellng.

          • 2. Re: Datagrid &lt;- XML attributes and text
            ::E1:: Level 1
            Sorry for the typos Tracy. I've tryed to make it short and clear to understand the problem. Here is (I hope) more litterate version :)

            - - - - - - -
            <DATA id="1">
            <NAME nick="jay">JACK</NAME>
            <SURNAME middle="what">JILL</SURNAME>
            <DATA />

            part of mxml file
            - - - - - - - - -

            url=" http://localhost/data.xml"

            private function getAttributeNick(item:Object, column:DataGridColumn):String
            return (item["NAME"]["nick"]);

            <!-- I cannot make this work but you'll get idea -->
            private function getAttributeUniversal(item:Object, column:DataGridColumn):String
            return (this["item."+ column.dataField]);

            <mx:DataGrid dataProvider="{dataFeed.lastResult.myDatas.DATA}" >

            <mx:DataGridColumn headerText="ID" dataField="@id"/>
            <mx:DataGridColumn headerText="NAME" dataField="NAME"/>
            <mx:DataGridColumn headerText="SURNAME" dataField="SURNAME"/>

            <-- this I cannot get to work -->
            <mx:DataGridColumn headerText="NICKNAME-!OK" dataField="NAME.@nick"/>
            <mx:DataGridColumn headerText="SUR2-!OK" dataField="SURNAME.@middle"/>

            <!-- this works but I would like not to write function for each attribute I may have -->
            <mx:DataGridColumn headerText="NICKNAME-OK" labelFunction="getAttributeNick"/>

            <!-- so I try to send in some data -->
            <mx:DataGridColumn headerText="SUR2 !OK" dataField="SURNAME.@middle" labelFunction="getAttributeUniversal"/>


            Thank you for your interest.