Subj : E4X: Filtering Predicate Operator
To : netscape.public.mozilla.jseng
From : McKinley, Richard
Date : Mon Aug 23 2004 07:23 pm
I have tried this two different ways. The following code matches the
examples in section 11.2.4 very closely. The results I want are all
nodes with a level of 1:
See the code below. Why am I only getting the first node with level="1"?
var tree =
;
var nodesWithFilteringPredicateOperator = tree..node.(@level == 1);
out.println(nodesWithFilteringPredicateOperator.toXMLString());
/* output:
*/
var nodesWithForEach = new XMLList();
var i = 0;
for each(var n in tree..node) {
with(n) {
if(@level == 1) {
nodesWithForEach[i++] = n;
}
}
}
out.println(nodesWithForEach.toXMLString());
/*output:
*/
Thanks,
McKinley
.