Answer the question
In order to leave comments, you need to log in
How to parse HTML with libxmljs?
I want to display the content of one node.
axios.get('example.com')
.then((res) => {
let xmlDoc = libxmljs.parseXml(res.data)
let gchild = xmlDoc.get('//*[@id="wrap"]/div[2]/div/div[2]/div[3]/article/header/h1')
console.log(gchild.text())
})
{ Error: Extra content at the end of the document
at Object.module.exports.fromXml (/home/***/Documents/WORK/SCRAPE-BOTS/axios-test/node_modules/libxmljs/lib/document.js:168:21)
at axios.get.then (/home/nman/Documents/WORK/SCRAPE-BOTS/axios-test/index.js:15:27)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) domain: 1, code: 5, level: 3, column: 2, line: 1 }
Answer the question
In order to leave comments, you need to log in
Error: Extra content at the end of the documentHave you checked what's in there?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question