[英]How do I grab all children nodes under the parent node in xml using flex?
I have a parent node and I'm trying to get each child node under that parent and store it into an arraycollection? 我有一个父节点,并且我试图获取该父节点下的每个子节点并将其存储到arraycollection中? How could I go by doing this?
我该怎么做?
var coll:ArrayCollection = new ArrayCollection();
for each ( var child:XML in parent.children()) {
coll.add(child);
}
parent.children() gives you all child nodes of parent as XMLList. parent.children()为您提供parent的所有子节点作为XMLList。 You can then add each child to the collection.
然后,您可以将每个孩子添加到集合中。
If you want to include only element nodes, you can use elements() instead of children(). 如果只想包含元素节点,则可以使用elements()代替children()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.