{"id":22356342,"url":"https://github.com/do-/node-xml-toolkit","last_synced_at":"2025-07-08T20:11:14.595Z","repository":{"id":57401863,"uuid":"427915801","full_name":"do-/node-xml-toolkit","owner":"do-","description":"XML parser, marshaller, SOAP adapter","archived":false,"fork":false,"pushed_at":"2025-07-07T14:34:46.000Z","size":662,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-07T14:54:21.579Z","etag":null,"topics":["sax","soap","xml","xsd"],"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/do-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-11-14T11:57:37.000Z","updated_at":"2025-07-07T14:34:49.000Z","dependencies_parsed_at":"2024-06-21T05:46:13.244Z","dependency_job_id":"2e0fe6b9-ece8-4f75-a665-77983cd488a9","html_url":"https://github.com/do-/node-xml-toolkit","commit_stats":{"total_commits":184,"total_committers":2,"mean_commits":92.0,"dds":0.05978260869565222,"last_synced_commit":"410f209095b143fa43a82b71ba484c16a8f16a1c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/do-/node-xml-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-xml-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-xml-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-xml-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-xml-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/do-","download_url":"https://codeload.github.com/do-/node-xml-toolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-xml-toolkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264341083,"owners_count":23593294,"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":["sax","soap","xml","xsd"],"created_at":"2024-12-04T14:09:56.404Z","updated_at":"2025-07-08T20:11:14.561Z","avatar_url":"https://github.com/do-.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![workflow](https://github.com/do-/node-xml-toolkit/actions/workflows/main.yml/badge.svg)\n![Jest coverage](./badges/coverage-jest%20coverage.svg)\n\n`node-xml-toolkit` is a pure node.js library for solving diverse XML related application tasks, e. g.:\n* scanning through multi gigabyte long XML files with a limited memory buffer;\n* invoke SOAP Web services given a WSDL, method name and a plain data object.\n\nIt features both (fast and simple, but greedy) [synchronous](https://github.com/do-/node-xml-toolkit/wiki/XMLParser) and (trickier to use, but robust and streaming capable) [asynchronous](https://github.com/do-/node-xml-toolkit/wiki/XMLReader) XML parsers along with various tools for writing well formed XML: [according to a schema](https://github.com/do-/node-xml-toolkit/wiki/XMLMarshaller) or [without any](https://github.com/do-/node-xml-toolkit/wiki/XMLPrinter).\n\n# Installation\n\n```\nnpm install xml-toolkit\n```\n\n# Using\n\n* [Parsing a small file completely](XMLParser)\n\n```js\nconst fs = require ('fs')\nconst {XMLParser} = require ('xml-toolkit')\n\nconst xml    = fs.readFileSync ('doc.xml')\nconst parser = new XMLParser  ({...options})\n\nconst document = parser.process (xml)\n\nfor (const element of document.detach ().children) {\n  console.log (element.attributes)\n}\n```\n\n* [Reading a Record List](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Reading-a-Record-List), streaming mode\n\n```js\nconst {XMLReader, XMLNode} = require ('xml-toolkit')\n\nconst records = new XMLReader ({\n  filterElements : 'Record', \n  map            : XMLNode.toObject ({})\n}).process (xmlSource)\n\n// ...then:\n// await someLoader.load (records)\n\n// ...or\n// for await (const record of records) { // pull parser mode\n\n// ...or\n// records.on ('error', e =\u003e console.log (e))\n// records.pipe (nextStream)\n\n// ...or\n// records.on ('error', e =\u003e console.log (e))\n// records.on ('data', record =\u003e doSomethingWith (record))\n```\n\n* [Getting a Single Element](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Getting-a-Single-Element), streaming mode\n\n```js\nconst {XMLReader, XMLNode} = require ('xml-toolkit')\n\nconst data = await new XMLReader ({\n  filterElements : 'MyElementName', \n  map            : XMLNode.toObject ({})\n}).process (xmlSource).findFirst ()\n```\n\n* [Patching XML](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Patching-XML)\n\n```js\nconst {XMLReader} = require ('xml-toolkit')\n\nlet xmlResult = ''; for await (const node of new XMLReader ().process (xmlSource)) xmlResult += \n    node.isCharacters \u0026\u0026 node.parent.localName === 'ThePlaceHolder' ? id : \n    node.xml\n```\n\n* [Serializing an Object According to an XML Schema](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Serializing-an-Object-According-to-an-XML-Schema)\n\n```js\nconst {XMLSchemata} = require ('xml-toolkit')\n\nconst data = {ExportDebtRequestsResponse: {\t\n  \"request-data\": {\n   // ...\n  }\n}\n\nconst xs = new XMLSchemata ('xs.xsd')\n\nconst xml = xs.stringify (data)\n\n/* result:\n\u003cns0:ExportDebtRequestsResponse xmlns:ns0=\"urn:...\"\u003e\n  \u003cns0:request-data\u003e\n    \u003c!-- ... and so on ... --\u003e\n*/\n```\n\n* Invoking a [SOAP 1.1](https://github.com/do-/node-xml-toolkit/wiki/SOAP11) or [SOAP 1.2](https://github.com/do-/node-xml-toolkit/wiki/SOAP12) Web Service\n\n```js\nconst http = require ('http')\nconst {SOAP11, SOAP12} = require ('xml-toolkit')\n\nconst soap = new SOAP11 ('their.wsdl') // or SOAP12\n\nconst {method, headers, body} = soap.http ({RequestElementNameOfTheirs: {amount: '0.01'}})\n\nconst rq = http.request (endpointURL, {method, headers})\nrq.write (body)\n```\n\n* [Implementing](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Implement-a-SOAP-Web-Service) a SOAP service\n\n```js\nconst {XMLSchemata, SOAP11, SOAP12, SOAPFault} = require ('xml-toolkit')\n\nconst SOAP = SOAP11 // or SOAP12\n\nconst xs = new XMLSchemata (`myService.wsdl`)\n\nlet body, statusCode; try {  \n  body = xs.stringify (myMethod (/*...*/))\n  statusCode = 200\n}\ncatch (x) {\n  body = new SOAPFault (x)\n  statusCode = 500\n}\n\nrp.writeHead (statusCode, {\n  'Content-Type': SOAP.contentType,\n})\n\nconst xml = SOAP.message (body)\nrp.end (xml)\n```\n\n# Motivation\n\nUnlike Java (with [JAXB](https://www.oracle.com/technical-resources/articles/javase/jaxb.html) and [JAX-WS](https://www.oracle.com/technical-resources/articles/javase/jax-ws-2.html)) and some other software development platforms dating back to late 1990s, the core node.js library doesn't offer any standard tool for dealing with XML.\n\nIt might be a binding of a well known external library ([libxml](https://gitlab.gnome.org/GNOME/libxml2) comes to mind first — as it's [built in PostgreSQL](https://www.postgresql.org/docs/current/functions-xml.html) in many popular distros, for example), but, alas, nothing viable of this sort seem to be available.\n\nPure js 3rd party modules are abundant, but after some real tasks based researches the author decided to start up yet another node.js DIY XML toolkit project to get the job done with:\n* minimum computing resources;\n* minimum lines of application code;\n* minimum external dependencies.\n\n# Limitations\n\nNo W3C specification is 100% implemented here. For instance, DTDs are not supported, so, in theory, any rogue XML file using such bizarre deprecated feature as [Entity Declarations](https://www.w3.org/TR/xml/#sec-entity-decl) may crash the local XML parser.\n\nThough `node-xml-toolkit` has some support for [XMLSchema](https://github.com/do-/node-xml-toolkit/wiki/XMLSchema), it cannot be used for validation. Here, XML Schema is used only as a template for outputting valid XML provided a correct set of input data. That means, each `decimal` will be formatted with proper `fractionDigits`, but no CPU cycle will be spent on checking whether the incoming 10 char string fully conforms to the [`date`](https://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/datatypes.html#date) lexical representation or not.\n\nIn short, `node-xml-toolkit` may produce incorrect results for some input data, especially for deliberately broken ones.\n\nThere are perfectly reliable external tools for XML validation: for instance, \n[xmllint](https://linux.die.net/man/1/xmllint) (used in the test suite here) do just fine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fnode-xml-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdo-%2Fnode-xml-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fnode-xml-toolkit/lists"}