JSPM

xmldom-format

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7999
  • Score
    100M100P100Q125391F
  • License MIT

format xml using @xmldom/xmldom

Package Exports

  • xmldom-format
  • xmldom-format/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xmldom-format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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