Questions tagged [node-html-parser]

node-html-parser is an NPM package for quickly parsing HTML strings into a basic DOM tree.

node-html-parser is designed to parse "massive HTML files" quickly and efficiently, returning a basic DOM structure that can be queried and manipulated. It is a popular NPM package with over a million downloads a week.

See the NPM listing for more information and instructions for proper usage: https://www.npmjs.com/package/node-html-parser

5 questions
2
votes
1 answer

NodeJS - Can't insert an element to a HTML document using node-html-parser

When I try to append a HTML element to an existing using "body.appendChild" I get the error "TypeError: node.remove is not a function" Here's what I'm doing: const fs = require('fs'); const parse =…
Tim Langner
  • 357
  • 3
  • 16
1
vote
1 answer

How to get the target line number and columns range in `pa11y`?

According to TypeScript typings the pa11y returns: interface ResultIssue { code: string; context: string; message: string; selector: string; type: string; typeCode: number; } Example value (looks line the TypeScript typings…
Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
0
votes
1 answer

element.innerHTML = 'test' not setting inner html, in node with node-html-parser

Can not do a replace operation, or set innerHTML or innerText on dom nodes in node with node-html-parser. var HTMLParser = require('node-html-parser'); var content = `

H1 Tag

Greggory Wiley
  • 660
  • 6
  • 16
0
votes
0 answers

How properly replace elements using node-html-parser library?

I am trying to replace all links in body to spans like this. map((body) => { let dom = parse(body.toString()); dom.querySelectorAll('a').forEach((link) => { dom.exchangeChild(link, parse(`lalala`)); }); …
karina
  • 789
  • 9
  • 26
0
votes
1 answer

Removing script from HTML string using node-html-parser

I have an API which receives a string containing HTML code and stores it in a database. I'm using node-html-parser package to perform some logic on the HTML. Among other things, I want to remove any potentially-malicious script. According to the…
Sam
  • 1,130
  • 12
  • 36