1.0.3 • Published 7 years ago

nodekogiri v1.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

nodekogiri

This class is a wrapper to xmllibjs that acts like Nokogiri

Install

npm install nodekogiri

Usage

const { HTML } = require('nodekogiri')

let html = `
<div class="foo">My List</div>
<ul>
  <li>aaa</li>
  hi
  <li>bbb</li>
  <li>ccc</li>
</ul>
<div>xxx</div>
`
let doc = new HTML(html)

let data = doc.search('.foo').map(div => {
   return {
     title: div.text(),
     list: div.search('+ ul li').map(li => li.text())
   }
})

console.log(data)

It's only for extraction at this point (no DOM manipulation) and it can do some things that cheerio can't do (like the above example). It also performs a bit better than cheerio.

console.log(doc.at('.foo').class) // => foo
console.log('' + doc.at('.foo')) // => <div class="foo">My List</div>
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago