hairbo wrote:
Hi Axel,
Thanks for the response. I think I sort of get what you're suggesting,
but what if the results XML looks like this:
<results>
<firstname>John</firstname>
<lastname>Doe</lastname>
</results>
You see the difference here between this example and my previous one,
right? There's no containing "<person>" element, only two sibling
nodes. In that case if I iterate over the XpathResult, as you suggest,
I'll get each sibling one at a time, rather than both together. So, in
this case, is what I want to do more or less impossible, or do I need
to build a new XMLDocument on the fly somehow?
Well, you can still do it, the only problem and significant difference
is that you loose the context nodeset for the second xpath expression.
If that's what's bothering you, sorry, no solution for that.
Axel
Axel Hecht wrote:
hairbo wrote:
Not sure if this is the best place for this question, so apologies if
it is not.
I would like to be able to run an Xpath query on the results returned
by the XPathResult "evaluate" function. I have a shell of XML, like
this:
<results>arbitrary results here</results>
...where the "arbitrary results" could be a string, or more XML, such
as:
<results>
<person>
<firstname>John</firstname>
<lastname>Doe</lastname>
</person>
</results>
If I run an Xpath query to get the contents of the "results" node, I
cannot then run another xpath query against those results.
I suppose the question is this: is there any way to "reset" the
returned value of "results" from an "XpathResult" back to an
"XmlDocument", or something like it?
The MSXML parser seems to have no difficulty running an xpath query on
a returned nodeset, so I'm struggling to see why this appears to be so
difficult in Mozilla's implementation. However, I'm fairly new to this
code, so perhaps I'm missing some basic principle here.
Any help would be appreciated.
I don't see why you shouldn't be able to do that, other than that we
don't take an XpathResult as argument to evaluate, but only dom nodes.
So you had to make that extra step and iterate over the result, get the
node, and then evaluate with that.
Not sweet, but works.
E4X allows you do to the thing you want directly, btw, but of course,
that's gecko only for now.
Axel
|