w3c-xmlserializer

WebJar for w3c-xmlserializer

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

w3c-xmlserializer
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

w3c-xmlserializer
WebJar for w3c-xmlserializer
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/jsdom/w3c-xmlserializer

Download w3c-xmlserializer

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/w3c-xmlserializer/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>w3c-xmlserializer</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/w3c-xmlserializer/
implementation 'org.webjars.npm:w3c-xmlserializer:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/w3c-xmlserializer/
implementation ("org.webjars.npm:w3c-xmlserializer:2.0.0")
'org.webjars.npm:w3c-xmlserializer:jar:2.0.0'
<dependency org="org.webjars.npm" name="w3c-xmlserializer" rev="2.0.0">
  <artifact name="w3c-xmlserializer" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='w3c-xmlserializer', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "w3c-xmlserializer" % "2.0.0"
[org.webjars.npm/w3c-xmlserializer "2.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : xml-name-validator jar [3.0.0,4)

Project Modules

There are no modules declared in this project.

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.
org.webjars.npm

Versions

Version
2.0.0
1.1.2
1.0.1