这是我的 XML 文件:
<cm>
<strategy_description>
<category name="Account">
<item name="tree">test1</item>
<item name="type">test2</item>
</category>
<category name="Account2">
<item name="tree">test1</item>
<item name="type">test2</item>
</category>
</strategy_description>
</cm>
我想输出这样的东西:
Account
tree: test1
type: test2
Account2
tree: test1
type: test2
我做到了这一点,并设法以 XML 格式跟踪输出所有类别和项目节点:
var categoryList:XMLList = xmlData.strategy_description.category;
for each(var category:XML in categoryList){
trace(category);
}