wgxpath
Wicked Good XPath
Last updated 9 years ago by jacobmarble .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install wgxpath 
SYNC missed versions from official npm registry.

node-wgxpath

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

Version

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.

Installation

Install with npm:

npm install wgxpath

Make sure things are working:

node node_modules/wgxpath/word_of_the_day.js

Example

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 = 'http://www.merriam-webster.com/word-of-the-day/';
var expressionString = '//*[@id="content"]/div[3]/ul/li[1]/strong';

jsdom.env({
  html: url,
  done: function(errors, window) {
    wgxpath.install(window);
    var expression = window.document.createExpression(expressionString);
    var result = expression.evaluate(window.document,
        wgxpath.XPathResultType.STRING_TYPE);
    console.log('The Word of the Day is "' + result.stringValue + '."');
  }
});

Current Tags

  • 1.2.0                                ...           latest (9 years ago)

9 Versions

  • 1.2.0                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           10 years ago
  • 0.23.0                                ...           10 years ago
  • 0.20.2                                ...           11 years ago
  • 0.20.1                                ...           11 years ago
  • 0.20.0                                ...           11 years ago
  • 0.12.1                                ...           12 years ago
  • 0.12.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE