Package detail

xmldom-format

AnWeber36.3kMIT2.0.0

format xml using @xmldom/xmldom

w3c, dom, xml, format

readme

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

changelog

2.0.0 (2024-10-27)

Features

  • update to @xmldom/xmldom@9.x

1.1.1 (2023-01-10)

Fix

  • NodeJS 14 error with ||=

1.1.0 (2022-12-31)

Feature

  • add formatOptions to XmlSerializer

1.0.0 (2022-12-20)

Feature

  • initial release