views:

1892

answers:

7

I'm looking for a XPath library to query over XML documents in FF, IE, Opera and Safari... and couldn't find one. Have you seen any?

+2  A: 

You could use the basic XPath plug-in for jQuery to get XPath query-ing functionality.

Also, you could consider reading this article on XPath XML processing (again with jQuery)

Alexander Gyoshev
Thanks! I've had a look at both. XPath plugin for jQuery simply converts XPath expression to the jQuery selection expression. It doesn't work even for simple cases.
Fyodor Sheremetyev
Does this work at all with jquery > 1.2?
ko-dos
+2  A: 

Take a look at http://dev.abiss.gr/sarissa/ project. They have migrated most of XML-related APIs to IE, as well as evaluate method on document object. And indeed, jQuery doesn't have an XPath processor, it has a very simple path selector like: /a/b/c only

Sergey Ilinsky
A: 

Also, Backbase Ajax Framework has complete (and very thoroughly tested) XPath 1.0 implementation, and major part of XPath 2.0

Sergey Ilinsky
A: 

I don't think it allows for ad-hoc queries, but you might take a look at Johann Burkard's XSLT jQuery plug-in for inspiration on how to implement XPath queries. I use it in my jQuery Reference Dashboard widget and it's really solid.

Andrew Hedges
+1  A: 

Google's AJAXSLT open source project fits well the stated requirements.

As their own description goes to say:

"AJAXSLT is an implementation of XSLT in JavaScript. Because XSLT uses XPath, it is also an implementation of XPath that can be used independently of XSLT. This implementation has the advantange that it makes XSLT uniformly available on more browsers than natively provide it, and that it can be extended to yet more browsers if necessary. AJAXSLT is interesting for developers who strive aggressively for cross browser compatibility of their advanced web applications. "

Dimitre Novatchev
A: 

You could make use of the existing native DOM support of each browser. For this you would have to create your own wrapper, the reason is the differences between browser. You can take a look at http://dotnetcaffe.blogspot.com

Best regards

michael
Thanks for the link! I had to gave up finding a library and implemented a simple browser-specific wrapper around native DOM. Will try to use yours.
Fyodor Sheremetyev
A: 

FormFaces (XForms implementation in JS) has a reliable XPath engine that can be easly extracted and used independently.

Bartbog