logo       

Re: Xpath query of XPathResult?: msg#00004

Subject: Re: Xpath query of XPathResult?
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



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe