Here are two quick ways of doing it, depending on whether you want child
nodes or the element itself. Both are shown in the trace so you can
experiment and modify this to suit your needs.

var myXML:XML = <ANIMALS>
    <MAMMALS>
        <MAMMAL>human</MAMMAL>
        <MAMMAL>cow</MAMMAL>
        <MAMMAL>dog</MAMMAL>
    </MAMMALS>
    <BIRDS>
        <BIRD>blackbird</BIRD>
        <BIRD>dove</BIRD>
        <BIRD>
            <BIRDIE>test</BIRDIE>
        </BIRD>
    </BIRDS>
    <FISHES>
        <FISH>fishAndChips</FISH>
        <FISH>goldfish</FISH>
        <FISH>herring</FISH>
        <FISH>shark</FISH>
        <MAMMAL>whale</MAMMAL>
    </FISHES>
</ANIMALS>;

function traceNode (xmlObj:XML, nodeName:String):void {
    for each (var element:XML in xmlObj..*) {
        if (element.name() == nodeName) {
            trace(element);
        }
    }
    trace("--");
    trace(xmlObj..*.(name() == nodeName));
}

traceNode(myXML, "FISH");


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to