{"id":18429648,"url":"https://github.com/jsdom/w3c-xmlserializer","last_synced_at":"2025-04-07T10:23:06.719Z","repository":{"id":46985922,"uuid":"135884402","full_name":"jsdom/w3c-xmlserializer","owner":"jsdom","description":"An XML serializer that follows the W3C specification.","archived":false,"fork":false,"pushed_at":"2023-11-12T07:59:11.000Z","size":282,"stargazers_count":21,"open_issues_count":3,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T08:08:51.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsdom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"tidelift":"npm/jsdom"}},"created_at":"2018-06-03T07:50:16.000Z","updated_at":"2024-05-11T21:05:53.000Z","dependencies_parsed_at":"2024-06-18T13:53:46.438Z","dependency_job_id":"00ab540f-38a6-47ef-8af6-8f5e198b9cb0","html_url":"https://github.com/jsdom/w3c-xmlserializer","commit_stats":{"total_commits":51,"total_committers":6,"mean_commits":8.5,"dds":"0.47058823529411764","last_synced_commit":"83115f8ecce8ed77a2a907c74407b2c671751463"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fw3c-xmlserializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fw3c-xmlserializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fw3c-xmlserializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fw3c-xmlserializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsdom","download_url":"https://codeload.github.com/jsdom/w3c-xmlserializer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247632517,"owners_count":20970174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:18:01.674Z","updated_at":"2025-04-07T10:23:06.692Z","avatar_url":"https://github.com/jsdom.png","language":"JavaScript","funding_links":["https://tidelift.com/funding/github/npm/jsdom"],"categories":[],"sub_categories":[],"readme":"# w3c-xmlserializer\n\nAn XML serializer that follows the [W3C specification](https://w3c.github.io/DOM-Parsing/).\n\nThis package can be used in Node.js, as long as you feed it a DOM node, e.g. one produced by [jsdom](https://github.com/jsdom/jsdom).\n\n## Basic usage\n\nAssume you have a DOM tree rooted at a node `node`. In Node.js, you could create this using [jsdom](https://github.com/jsdom/jsdom) as follows:\n\n```js\nconst { JSDOM } = require(\"jsdom\");\n\nconst { document } = new JSDOM().window;\nconst node = document.createElement(\"akomaNtoso\");\n```\n\nThen, you use this package as follows:\n\n\n```js\nconst serialize = require(\"w3c-xmlserializer\");\n\nconsole.log(serialize(node));\n// =\u003e '\u003cakomantoso xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\u003c/akomantoso\u003e'\n```\n\n## `requireWellFormed` option\n\nBy 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\n\n```js\nserialize(node, { requireWellFormed: true });\n```\n\nwhich will cause `Error`s to be thrown when non-well-formed constructs are encountered. [Per the spec](https://w3c.github.io/DOM-Parsing/#dfn-require-well-formed), this largely is about imposing constraints on the names of elements, attributes, etc.\n\nAs a point of reference, on the web platform:\n\n* The [`innerHTML` getter](https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml) uses the require-well-formed mode, i.e. trying to get the `innerHTML` of non-well-formed subtrees will throw.\n* The [`xhr.send()` method](https://xhr.spec.whatwg.org/#the-send()-method) does not require well-formedness, i.e. sending non-well-formed `Document`s will serialize and send them anyway.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fw3c-xmlserializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsdom%2Fw3c-xmlserializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fw3c-xmlserializer/lists"}