node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »



Wicked Good XPath is a fast implementation of document.createExpression and document.evaluate (DOM3-XPath) in pure Javascript.


x.y.z: x.y refers to the Wicked Good XPath revision when wgxpath.install.js was built; z refers to any improvements to this package.

I'm pretty lazy, so I don't build Wicked Good XPath myself. When the pre-compiled wgxpath.install.js is updated, I'll update this package.


Install with npm:

npm install wgxpath

Make sure things are working:

node node_modules/wgxpath/word_of_the_day.js


This example scrapes the Merriam-Webster Word of the Day. This code can also be found in word_of_the_day.js. Be sure to install jsdom 3.x before running the example.

$ npm install jsdom@"<4"
var wgxpath = require('wgxpath');
var jsdom = require('jsdom');
var url = '';
var expressionString = '//*[@id="content"]/div[3]/ul/li[1]/strong';
  html: url,
  done: function(errors, window) {
    var expression = window.document.createExpression(expressionString);
    var result = expression.evaluate(window.document,
    console.log('The Word of the Day is "' + result.stringValue + '."');