Flex e4x filter out children
I'm trying to filter my xml so that the childnodes are not displayed. This xml will then be used as a dataprovider for my advanceddatagrid. Given this XML :
<item text="folder1" display="true">
<item text="folder2" display="true">
<item text="node" display="true">
<item display="false">
<property1>val1</property1>
<property2>val2</property2>
</item>
</item>
</item>
</item>
What I want is an XML with only the nodes that have the property display set to true. So, the resulting XML should be:
<item text="folder1" display="true">
<item text="folder2" display="true">
<item text="node" display="true">
</item>
</item>
</item>
开发者_如何学运维
When I try trace(data.item.(@display == 'true'));
every node is still displayed, even the ones with display false..
Any help would be appreciated ..
okay, this is how I solved it now :
var childNodes:XMLList = new XMLList(data.descendants("item").(@display == 'false'));
for ( var i:int = childNodes.length() - 1; i >= 0; i-- ) {
delete childNodes[i];
}
I think this is happening because of the format of that XML.
All of the item elements under folder1 are child nodes of folder1. Since it has display="true", then the trace will display all of its children.
Anyone else, is this XML formatted correctly to do the search?
精彩评论