Skip to content

Instantly share code, notes, and snippets.

@hekike
Created May 17, 2014 10:50
Show Gist options
  • Save hekike/103adb574e882e578115 to your computer and use it in GitHub Desktop.
Save hekike/103adb574e882e578115 to your computer and use it in GitHub Desktop.
htm-select attr selector: *=, ^= $=
var select = require('../');
var tokenize = require('html-tokenize');
var fs = require('fs');
var s = select('ul > li dt[name*="sample"]', function (e) {
console.log('*** MATCH ***');
e.createReadStream().on('data', function (row) {
console.log([ row[0], row[1].toString() ]);
});
});
fs.createReadStream(__dirname + '/page.html').pipe(tokenize()).pipe(s);
s.resume();
@hekike
Copy link
Author

hekike commented May 17, 2014

Throws error with these selectors:

[attr$=value]: Attribute ends with value
[attr^=value]: Attribute starts with value
[attr*=value]: Attribute contains value
[attr~=value]: Attribute, split by whitespace, contains value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment