2 Replies Latest reply on Jul 1, 2011 11:21 AM by HarishTVN

    Handling dots in XML data

    HarishTVN

      Hi. I have a XML data tags as mentioned below, i need to use these tags in my Datagrid column.

       

      I tried using with braces also but nothing is showing in the output.

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" x="102" y="53" layout="absolute">
      <mx:Script>
        <![CDATA[
         [Bindable]
         public var dataXML:XML =
          <ROWSET>
          <ROW>
            <_Markets_._Market_>ATLANTA</_Markets_._Market_> 
            </ROW>
           <ROW>
            <_Markets_1_Market_>BIRMINGHAM</_Markets_1_Market_>
            </ROW>
          </ROWSET>;
        ]]>
      </mx:Script>
      <mx:DataGrid x="102" y="53" width="476" height="152" dataProvider="{dataXML.ROW}">
        <mx:columns>
         <mx:DataGridColumn headerText="Market" dataField="_Markets_._Market_" />
        </mx:columns>
      </mx:DataGrid>
      </mx:Application>

       

      Please help...

       

      Thanks.

        • 1. Re: Handling dots in XML data
          blazejewicz Level 4

          Hi,

           

          You've very unfortunate entity names for automatic conversion I think:

          - they contains dot which is non-allowed for actionscript variable names (but will work anyway at runtime - but do not expect to be able to use dot in code when naming something)

          - there are different element names (nodes) for given level

           

          Here is solution you could try:

          Grid:

          <mx:DataGrid width="100%" height="100%">
               <mx:columns>
                    <mx:DataGridColumn headerText="Market" labelFunction="labelFunction"/>
               </mx:columns>
               <mx:dataProvider>
                    <mx:XMLListCollection source="{dataXML.ROW}"/>
               </mx:dataProvider>
          </mx:DataGrid>
          

           

          and code:

           

          protected function labelFunction(item:Object, column:DataGridColumn):String
          {
               var node:XML = item as XML;
               var value:String = node.child(0);
               return value;
          }
          

           

           

          I think there is something deep in mx.* code for automatic conversion that fails to correctly translate your entity names into object property names when assigned to data provider instance - but I think above would work (you should re-design your xml though I think),

           

          regards,

          Peter

          • 2. Re: Handling dots in XML data
            HarishTVN Level 1

            Hi Peter,

             

            It worked... thanks..