DOM 3 XPath in Web Kit

Last week the WebKit team announced support for DOM Level 3 XPath in the nightly builds.

If you want to play with that, there’s a tutorial on Mozilla’s XPath support, which has live examples that work with WebKit.

Native XPath in the browser means we can ditch the expensive calls to document.getElementsByClassName() in our libraries.

Possibly Related posts (machine generated):

  1. From JSON to XPath
  2. Mozilla XPath Documentation
  3. Development Link Blogging
  4. Prototyping One-to-many Links with XSLT
  5. Tibet JavaScript Libraries

More like this: .

  • geecu
    I've tested it (FF and Safari on Mac), //div[@class="class"] is about 20 times *slower* than getElementByClassName. Maybe I was doing something wrong... have you tested it?
  • @ jmdesp: no doubt that a native version of getElementBySelector would be fast. It's one of the items the WHAT-WG considering.

    But given the choice between Prototype's getElementsByClassName(), and a native XPath expression, I'll take the later.
  • jmdesp
    I don't understand. Why would byClassName be more expensive to implement than xpath ? Or is it because you can't point to exactly what you want and need expensive enumerations ?
    Whatever getElementById will always be the fastest choice, and it's better to reorganise the page in order to use it.
blog comments powered by Disqus