Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

w3c-xmlserializer

Package Overview
Dependencies
1
Maintainers
6
Versions
12
Issues
File Explorer

Advanced tools

w3c-xmlserializer

A per-spec XML serializer implementation

    4.0.0latest

Version published
Maintainers
6
Weekly downloads
15,040,999
decreased by-12.24%

Weekly downloads

Changelog

Source

4.0.0

The minimum required Node.js version is now v14.

When the requireWellFormed option is passed, emoji are now correctly allowed. (@hata6502, #27)

Readme

Source

w3c-xmlserializer

An XML serializer that follows the W3C specification.

This package can be used in Node.js, as long as you feed it a DOM node, e.g. one produced by jsdom.

Basic usage

Assume you have a DOM tree rooted at a node node. In Node.js, you could create this using jsdom as follows:

const { JSDOM } = require("jsdom"); const { document } = new JSDOM().window; const node = document.createElement("akomaNtoso");

Then, you use this package as follows:

const serialize = require("w3c-xmlserializer"); console.log(serialize(node)); // => '<akomantoso xmlns="http://www.w3.org/1999/xhtml"></akomantoso>'

requireWellFormed option

By default the input DOM tree is not required to be "well-formed"; any given input will serialize to some output string. You can instead require well-formedness via

serialize(node, { requireWellFormed: true });

which will cause Errors to be thrown when non-well-formed constructs are encountered. Per the spec, this largely is about imposing constraints on the names of elements, attributes, etc.

As a point of reference, on the web platform:

  • The innerHTML getter uses the require-well-formed mode, i.e. trying to get the innerHTML of non-well-formed subtrees will throw.
  • The xhr.send() method does not require well-formedness, i.e. sending non-well-formed Documents will serialize and send them anyway.

Keywords

FAQs

What is w3c-xmlserializer?

A per-spec XML serializer implementation

Is w3c-xmlserializer popular?

The npm package w3c-xmlserializer receives a total of 12,000,276 weekly downloads. As such, w3c-xmlserializer popularity was classified as popular.

Is w3c-xmlserializer well maintained?

We found that w3c-xmlserializer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 6 open source maintainers collaborating on the project.

Last updated on 20 Nov 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc