Document JavaScript XPath usage



Web Developer
14 years ago
2 years ago


(Reporter: Heikki Toivonen (remove -bugzilla when emailing directly), Assigned: Axel Hecht)




We need a small blurb on that we support
the DOM Level 3 XPath API, a link to the spec, and a small example like we have
for XSLT from JS in here:

Also I would advice changing the main XSLT title to include XPath, something like:

XSL Transformations (XSLT) and XPath in Mozilla

I have gotten several requests recently asking about our XPath API support and
the best I could do was point them to the spec and the XSLT page. There
isna'treally anything that tells them we support it and figuring things out from
the spec is not trivial.
Forgot the spec link, here it is:
I can check in the files if someone just provides the content...

Comment 3

14 years ago
You might get more responses if you posted a 1-2 paragraph description of how
this all works in this bug, to get things started. Someone else might take an
interested, learn about XPath, and write the document, you never know :)

Comment 4

14 years ago
excuse me, we know that you want docs. Everybody does. Stop nagging.
There are more important things on the lists of those that actually would
contribute the content. There are even more important docs.

Comment 5

14 years ago
Seeing this bug I was playing with it once again:

A) I've downloaded MSXML 4.0 SP2, installed it, searched help, copied example
and in less then 15 minutes I've got the results I'd expected to get.

B) I've tried the same for DOM3 XPath and Mozilla willing to write the docs. In
about two hours I completely lost my feeling I understood it. And it's only two
weeks I needed XPath in some script... Perhaps wrong build number (20030605),
who knows...

OK, maybe I'm dumb. Oh yeah, from what I've heard from people trying to use
XPath2, XSLT2 and other XMLSchema based trash, I'm not the only one.

Comment 6

13 years ago
Hmm. I could maybe do this. How much information is required? Somthing like:
Basic calls (document.evaluate)
Return types (snapshots / iterators)
Namespace resolvers (difference between XHTML and HTML)

Or something less specific?

Comment 7

13 years ago
Thank you for volunteering.

We should have examples for the common return types, and how to work on HTML and
XML documents, the latter with and without namespaces. Make an example using
a node as namespace resolver as well as an explicit js one, so that users see
how to work with default namespaces.

This sounds like quite a bit of work, but I'd be fine with landing this in chunks.

Comment 8

13 years ago
OK, so I've done a little here but work has temporarily stalled. There's a
snapshot of the work-in-progress at

Comment 9

13 years ago
(In reply to comment #8)
> OK, so I've done a little here but work has temporarily stalled. There's a
> snapshot of the work-in-progress at

I looked over this, it's a pretty good start. A few comments though. On the 
source, content is short lines, not a single line per paragraph.
The markup is probably allright, didn't check that closely. I assume that you 
followed, as you use the 
m.o stylesheets already.

I'm no big fan of //foo expressions, as you used them like /descendent::foo,
which is faster. In most cases, it won't really matter, but I'd prefer to see
us giving good examples (yes, one can optimize that in the engine, too).

In the XML part, you should call HTML XHTML, just to make the difference clear.
Are you going to provide us with an example, too?

There are a few edges in the english, but I guess we'll iron those out later.
IMHO //foo expressions are clearer to read so I think that's what should be used
in helppages. It might be a good idea to have an optimization section though
where // vs. descendant:: is discussed.
QA Contact: rudman
This bug has been buried in the graveyard and has not been updated in over 10 years. It is probably safe to assume that it will never be fixed, so resolving as WONTFIX.

Please file new issues against MDN in the "Developer Documentation" product.
Last Resolved: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.