xmldom-format
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

xmldom-format

XMLSerializer to serialize and format Document

Installation

npm install xmldom-format

Usage

XMLSerializer

use XMLSerializer.serializeToString(rootNode) to serialize Document without FormatOptions

  import { XMLSerializer } from "xmldom-format";
  const rootNode = new DOMParser().parse(`<html><body>Hello<br/>World</body></html>`);
  const xmlSerializer = new XMLSerializer();
  console.info(xmlSerializer.serializeToString(rootNode)); // <html><body>Hello<br/>World</body></html>

formatXml

use formatXml to serialize and format Document with FormatOptions

  import { formatXml } from "xmldom-format";
  const rootNode = new DOMParser().parse(`<html><body>Hello<br/>World</body></html>`);
  console.info(formatXml(rootNode, { useWhitespaceInAutoClosingNode: true})); // <html><body>Hello<br />World</body></html>

License

MIT License

Change Log

CHANGELOG

Dependencies (0)

    Dev Dependencies (14)

    Package Sidebar

    Install

    npm i xmldom-format

    Weekly Downloads

    7,846

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    40.3 kB

    Total Files

    34

    Last publish

    Collaborators

    • weber.andreas