Question: I'm into some web scraping with Node.js. I'd like to use XPath as I can generate it semi-automatically with several sorts of GUI. The problem is that I cannot find a way to do this effectively.

1. `jsdom` is extremely slow. It's parsing 500KiB file in a minute or so with full CPU load and a heavy memory footprint.
2. Popular libraries for HTML parsing (e.g. `cheerio`) neither support XPath, nor expose W3C-compliant DOM.
3. Effective HTML parsing is, obviously, implemented in WebKit, so using `phantom` or `casper` would be an option, but those require to be running in a special way, not just `node <script>`. I cannot rely on the risk implied by this change. For example, it's much more difficult to find how to run `node-inspector` with `phantom`.
4. `Spooky` is an option, but it's [buggy enough](https://github.com/WaterfallEngineering/SpookyJS/issues/71), so that it didn't run at all on my machine.

What's the right way to parse an HTML page with XPath then?

Answer: 
I have just started using [`npm install htmlstrip-native`](https://github.com/zaro/node-htmlstrip-native) which uses a [native implementation](https://github.com/zaro/node-htmlstrip-native/blob/master/htmlstrip.cpp) to parse and extract the relevant html parts. It is claiming to be 50 times faster than the pure js implementation (I have not verified that claim).

Depending on your needs you can use html-strip directly, or lift the code and bindings to make you own C++ used internally in htmlstrip-native

If you want to use xpath, then use the wrapper already avaialble here;
 <https://www.npmjs.org/package/xpath>
With just one line, you can do it with [`xpath-html`](https://www.npmjs.com/package/xpath-html):

```js
const xpath = require("xpath-html");

const node = xpath.fromPageSource(html).findElement("//*[text()='Made with love by']");

```