xmlactionscript-3flashidentifiere4x

Parsing XML with nodes containing underscores


How do I parse an XML document that contains nodes where underscores exist?

<some_xml>
    <child_node>
        <child width_info="" height_info="" />
    </childnode>
</some_xml>

I tried this:

for each (var item:XML in Environment._XMLData.some_xml.child_node.child){
    trace(child.@width_info);
}

But that does'nt seem to work. I can't change the XML either because its from a third party. Any help would be great. Thanks in advance!


Solution

  • The problem is that some_xml is your root node, so you don't need to include that.

    This should work:

    for each (var item:XML in Environment._XMLData.child_node.child){
        trace(item.@width_info);
    }