This is just a simple question. I’m currently using Mozilla’s Rhino to develop a little webapp. As one step, I need to get a webpage and filter all of it’s nodes. For doing that, I use E4X. I thought I could do this like that:
var pnodes = doc..*(p);
But that produces an error. How is it done right?
(BTW: this is just a step for increasing performance. The code already does well, it’s just a bit slow.)
You should be able to use the following:
Note that this there is a bug in the Rhino and SpiderMonkey implementations where the filter expression
name() == "p"is not correctly scoped to the current node, so none of theXMLorXMLListmethods are defined.Another workable solution is to lookup all
pnodes in the document and accumulate the parent of each in an array.