Filtrate XMLList using ".." notation
There is something I couldn't solve: when I search a specific node in a XMLList containing several level of hierarchy, filter never search in the top parent node.
For example, if I have a tree like this:
<node id="a0KQ0000002PTN5MAO" parentId="">
<node id="a0KQ0000002PT8iMAG" parentId="a0KQ0000002PTN5MAO" />
</node>
and if I made a reseach like this:
var aNode = ac_hierarchy.source..node.(@id == "a0KQ0000002PTN5MAO")[0];
I will get no results, "aNode" will be null :/
Any idee ?
[EDIT] There is something else I can't understand (and I'm searching for 2 days :/):
I recursively add nodes to the ac_hierarchy using the method bellow:
private function add_item_to_hierarchy(node:Node_vo):XML {
var firstNode:XML = ac_hierarchy.getItemAt(0) as XML;
var parentNode:XML;
if (firstNode.@[Node_vo.att_id] == node.parentId)
parentNode = firstNode;
else
parentNode = ac_hierarchy.source..node.(@[Node_vo.att_id] == node.parentId)[0];
var test:XML = ac_hierarchy.source..node.(@[Node_vo.att_id] == node.parentId)[0];
var test2:XML = ac_hierarchy.source..node.(@[Node_vo.att_id] == "a0KQ0000002PT8iMAG")[0];
newXmlNode = node.toXML();
// Add the current node to his parent node
parentNode.appendChild(newXmlNode);
}
The first time I call the "add_item_to_hierarchy" with "node.parentId" parameter equals to "a0KQ000000开发者_运维问答2PTN5MAO" method, ac_hierarchy looks like:
<node id="a0KQ0000002PTN5MAO" parentId="" />
var test:XML is filled.
var test2:XML is not filled.
It correctly appendChild.
The second time, "node.parentId" parameters equals to "a0KQ0000002PT8iMAG" and ac_hierarchy looks like:
<node id="a0KQ0000002PTN5MAO" parentId="">
<node id="a0KQ0000002PT8iMAG" parentId="a0KQ0000002PTN5MAO"/>
</node>
var test:XML is filled.
var test2:XML is filled.
It also correctly appendChild.
And the third time, "node.parentId" parameters again equals to "a0KQ0000002PT8iMAG" and ac_hierarchy looks like:
<node id="a0KQ0000002PTN5MAO" parentId="">
<node id="a0KQ0000002PT8iMAG" parentId="a0KQ0000002PTN5MAO">
<node id="a0KQ0000002PTL9MAO"/>
</node>
</node>
var test:XML is NOT filled.
var test2:XML is filled.
But this time, var "test" is null (although "node.parentId" value is the same as previous loop and test2 is correctly fill) !!!
I will soon break my computer :/
Thanks for your help.
Yes, xml selectors don't check root node, but there are workarounds:
Get your parent node into proxy XMLList and search it:
var list:XMLList = new XMLList();
list[0] = <node id="1"/>;
var results:XMLList = list.(@id == "1");or just check parent node separately and add to search results.
精彩评论