-1

My node is:

<node Dep_MandMARA_SATNR="H_H_H" Dep_MandMARCSTDPD="H_H_H" MARA_SATNR="" MARCSTDPD="" MATL_GROUP="001" MATL_TYPE="ZCNI" rendReq="no" sno=""/>

It is stored in item:Object

I have to retrieve MATL_GROUP from it.

Please provide me solution.

ketan
  • 19,129
  • 42
  • 60
  • 98

2 Answers2

0

You should use the XML class to work efficient with xml-nodes.

In this case you could do it like this:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           minWidth="955" minHeight="600" creationComplete="init()">
<fx:Script>
    <![CDATA[
        import mx.controls.Alert;

        private var xml:XML = new XML(
            <node Dep_MandMARA_SATNR="H_H_H" Dep_MandMARCSTDPD="H_H_H" MARA_SATNR="" MARCSTDPD="" MATL_GROUP="001" MATL_TYPE="ZCNI" rendReq="no" sno="513314681"/>
        );

        protected function init():void
        {
            var matlGroup:String = xml.@MATL_GROUP;
            Alert.show(matlGroup);
        }

    ]]>
</fx:Script>
</s:Application>

If you want to be able to use any property name dynamically, do it like this:

        protected function init():void
        {
            var attrName:String = "MATL_TYPE";
            var matlGroup:String = xml.@[attrName];
            Alert.show(matlGroup);
        }
Anton
  • 4,544
  • 2
  • 25
  • 31
  • thnx for the ans.... but i want to retrieve the element dynamically. means I have MATL_GROUP or any other element name in a string. I want to retirve using that string.. – akshat.jain2731 Apr 22 '13 at 05:16
  • i want to retrieve any of the element which should be decided at run time.. in that case what syntax i use to retrieve element. xml.@MATL_GROUP is working. – akshat.jain2731 Apr 22 '13 at 05:21
  • I have added another example to my answer. Is it what you want? – Anton Apr 22 '13 at 06:24
  • the first version works by me fine. May be it depends on SDK. Thanks for the tip! – Anton Apr 24 '13 at 11:08
0

xml.@[attrName] is not working.... xml["@"+attrName];