5.0.0 • Published 5 months ago

w3c-xmlserializer v5.0.0

Weekly downloads
9,893,977
License
MIT
Repository
github
Last release
5 months ago

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.
jsdomreact-native-bluetooth2ticket-jsdomspecify-importsbabel-specify-importsreact-native-template-rfbaseairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationreact-native-covid-sdkgql_din_modbitget@olivervorasai/sliderreact-native-printer-brotherswilscannercreate-renderordersstretch-rollup@mink-opn/build-tokenssvelte-slimeplginexpand-react-bridgesklif-ui-kitsklif-api@everything-registry/sub-chunk-3108p149-table@pmadhur/jsdomsklif-uiflk-parserfront-and-backes-react-bridgeepm-npm-tscex-ikon-components-libraryevanutilshot-zone-vuedskcorenewdrift-npmgrids-over-polygongogencygogency-test-2google-remakegzup-react-image-file-resizerhexyun.helpersgenerator-bootstrap-boilerplate-templatejsdom-no-cssjsdom-rnjsdom-arc-extnjsdom-denojsdom-extra-jsjsdom-bypassjsdom-canvasjsdom-lambdajsdom-napi-rs-canvasjulien-easy-modallancetyersemproj3@simstudio/htmldiffp147-tablep148-tablenpm_qwertynumhandlernpm-package-mentorchecknotion-database-exporternpm_one_12_34_1_npm_one_1_2_3npm_one_2_2native-apple-loginnative-google-loginnative-kakao-loginmpesa-cookiempesa-cookie-jarmynancemy-library-buttonpayutestingpickupbiz-npm-packagenka-gantt-task-reactoracle-zkappmavectralight-jsdomlib-errormama-exportermap-values-resolvermggauharmd-vditormicroend-componentmoonwalkerswap-default-token-listsmy-calc-boxmy-greeter-packagemobtimer-api2neural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2new-example-projectraact-native-arunramya151qaapio-reecord-mp3pyreswap-sdkr2epubtestapasyncbackbasestailwind-vector-effect
5.0.0

5 months ago

4.0.0

1 year ago

3.0.0

3 years ago

2.0.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.0.4-0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago