Re: XPath and find/findAll methods

On 2011-11-21 20:34, Martin Kadlec (BS-Harou) wrote:
> Hello everyone, I've noticed that the find/findAll methods are
> currently being discussed and there is one thing that might be a good
> idea to consider.
>
> Currently, it's quite uncomfortable to use XPath in javascript. The
> document.evalute method has lots of arguments and we have to remember
> plenty of constants to make it work. IE and Opera support selectNodes
> method on NodePrototype, which is really useful, but what's the point
> in using it when it doesn't work in FF/Chrome/Safari.
>
> My idea is to combine querySelector/All and selectNodes methods. This
> combination - find/findAll - would make using XPath much easier and
> it might give a good reason to lot's of programmers to use it instead
> of querySelector/All although it's going to be newer technology.

This idea seems similar to how JQuery used to support both Selectors and 
XPath in the same API [1].  Support was subsequently removed in 1.2, and 
at the time moved to an XPath Compatibility Plugin [2].  However, the 
link to the actual plugin page now returns a 404, and I can't find that 
plugin or any replacement elsewhere.

This seems to suggest that support for XPath was not considered 
important enough for its continued maintenance.

Are there any other popular libraries that do still offer XPath APIs, or 
is there any data showing that authors really want to use it?

[1] http://docs.jquery.com/DOM/Traversing/Selectors#XPath_Selectors
[2] http://docs.jquery.com/Release:jQuery_1.2#XPath_Compatibility_Plugin

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Tuesday, 22 November 2011 12:32:28 UTC