Function parse

  • Parses an HTML string.

    Type Parameters

    Parameters

    • html: string

      Input HTML string.

    • Optionaloptions: ParserOptions<T>

      Parsing options.

    Returns T["document"]

    Document

    const parse5 = require('parse5');

    const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');

    console.log(document.childNodes[1].tagName); //> 'html'