views:

18

answers:

2

My xml is like below

<rat>
    <to>tt</to>
    <from>ggg</from>
    <heading>hhhhh</heading>
    <body>jjj</body>
</rat>

My AS3 code is

var example:XML = new XML(event.target.data);
_label.text = example[0].rat[0][nodeName];
addChild(_label);

I want to display the data like

to  = tt
from = ggg

how can i do that

+2  A: 
var example:XML = <rat>
    <to>tt</to>
    <from>ggg</from>
    <heading>hhhhh</heading>
    <body>jjj</body>
</rat>;

for each (var node:XML in example.*)
{
    trace(node.localName(), "=", node);
}
Typeoneerror
trace is not working in my IE . is there any other way to display the result on screen
Mirage
yeah, trace is an internal debugging function. if you want to display the result, you'll need to create a textfield and set the "text" or "htmlText" property to the output. var t:TextField = new TextField(); t.text = node.localName() + "=" + node; addChild(t);
Typeoneerror
+1  A: 

you want: xml.branch.node.name();

see XML in Flash CS3/AS3

shortstick