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.

The problem is how to combine the methods, because in some cases it might not 
be clear if the string is xpath or css query. Because CSS queries are probably 
going to be used much more often than xpath it should be easier to call the 
method with CSS query. There is an idea I have but I would be glad for any 
other.

findAll(query, use_xpath):
CSS: findAll("nav a:first-child");
XPATH: findAll("//nav/a[1]", true);

Cheers,
Martin Kadlec


Reply via email to