繁体   English   中英

是否可以在XML AS3 Flash中获取特定节点的子级

[英]Is it possible to get specific node's children in XML AS3 Flash

我有许多孩子的xml文件,然后有更多孩子。

喜欢

<level1>
<child id=1 > <nodes....> </child1>
<child id=2 > <nodes....> </child1>
<child id=3 > <nodes....> </child1>
<child id=4 > <nodes....> </child1>
</level1>

是否有可能在AS3中获得id = 1的child的子节点

我现在没有时间详细回答,但是请阅读e4x,它可以让您完成所需的工作。 稍后我将尝试发布一个示例。

是的,可以在xml上使用过滤器功能:

var xml:XML=<level1>
<child id="1" > <nodes>1</nodes> </child>
<child id="2" > <nodes>2</nodes> </child>
<child id="3" > <nodes>3</nodes> </child>
<child id="4" > <nodes>4</nodes> </child>
</level1>;

// list of children with id=1
var xl:XMLList=xml.child.(@id=="1"); //<== here filter xml based on attribute "id"
for each (var node:XML in xl){
  trace(node.toString());
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM