rafaelmaeuer
2/8/2017 - 5:01 PM

access xml childs through the variable name - From http://stackoverflow.com/questions/15174238/accessing-actionscript-3-xml-with-node-names-

        var xml:XML = 
            <root>
                <white>
                    <john>john white</john>
                    <bill>bill white</bill>
                    <pete>pete white</pete>
                </white>
                <black>
                    <john>john black</john>
                    <bill>bill black</bill>
                    <pete>pete black</pete>
                </black>
            </root>

        var colorName:String = "white";
        var menName:String = "bill";

        //example using []
        var nodeTextVar:String = xml[colorName][menName][0];
        trace(nodeTextVar);

        //example using XMLList.child(name)
        nodeTextVar = xml.child(colorName).child(menName)[0];
        trace(nodeTextVar);