user3685452
user3685452

Reputation: 7

How I can read all nodes of external xml file?

How I can read all nodes of xml file in two state: 1- if I don't know the name of nodes. 2- if l know the name of nodes.

note: I can load and see the file, but I want the methods that make access to each nodes. So I can do some function for each node. Thanks.

var txml:XML;
var xmlloader:URLLoader = new URLLoader();
    xmlloader.load(new URLRequest("‫‫ole.xml"));
    xmlloader.addEventListener(Event.COMPLETE,loaded);<br/>
function loaded(e:Event):void
    {   txml = new XML(xmlloader.data);
        var childNo:int; var namea: String; var sex:String;
        var id:int;
        namea= txml.@name; sex= txml.@sex;id = txml.@level;
        childNo= txml.@child;
        trace(childNo);
        trace(namea);
        trace(sex);
        trace(id);
        addmc(namea);}

Upvotes: 0

Views: 50

Answers (1)

Andrey Popov
Andrey Popov

Reputation: 7510

There are few ways to get the children.

child property will return XMLList and will let you search by child name

children just gives you all the children of specific node, no matter of the names

descendants will give even nested ones (can be searched by name)

There might be even more, you can look at the documentation, but these are the most common ones.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html

Upvotes: 1

Related Questions