DomParser

DomParser

Parse XML text to a Document Object Model. You should call .destroy() when done, or you will leak memory from the parser WASM instance.

Constructor

new DomParser(optionsopt)

Description:
  • Create a DOM Parser.
Source:
Parameters:
Name Type Attributes Description
options ParserOptions <optional>
Encoding to expect from Buffers/etc that are passed to parse()

Classes

DomParser

Methods

destroy()

Description:
  • Destroy this instance, cleaning up parser resources.
Source:

parse(str, finalopt) → {dom.Document}

Description:
  • Parse a chunk of an XML document. You can call this multiple times with final=0, then with final=1 when you're done.
Source:
Parameters:
Name Type Attributes Default Description
str string | Buffer | Uint8Array | Uint8ClampedArray
final number <optional>
1 If the last chunk of a document, 1. Otherwise use 0.
Returns:
The parsed document, if successful and this was the final chunk. Otherwise 0.
Type
dom.Document

(static) fromString(template, …sub)

Description:
  • Process a tagged template literal containing XML. Streams data into the parser per-chunk.
Source:
Parameters:
Name Type Attributes Description
template Array.<string> Template pieces
sub string <repeatable>
Substitutions

(static) parseFull(txt, opts) → {dom.Document}

Description:
  • Parse a full document.
Source:
Parameters:
Name Type Description
txt string | Buffer | Uint8Array | Uint8ClampedArray The text to parse.
opts ParserOptions
Returns:
The created document.
Type
dom.Document