npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xml-toolkit

v1.1.4

Published

XML parser, marshaller, SOAP adapter

Readme

workflow Jest coverage Ask DeepWiki

node-xml-toolkit is a pure node.js library for solving diverse XML related application tasks, e. g.:

  • scanning through multi gigabyte long XML files with a limited memory buffer;
  • invoke SOAP Web services given a WSDL, method name and a plain data object.

It features both (fast and simple, but greedy) synchronous and (trickier to use, but robust and streaming capable) asynchronous XML parsers along with various tools for writing well formed XML: according to a schema or without any.

Installation

npm install xml-toolkit

Usage

const fs = require ('fs')
const {XMLParser, XMLSchemata} = require ('xml-toolkit')

const xml    = fs.readFileSync ('doc.xml')
// const xs  = new XMLSchemata ('schema.xsd')

const parser = new XMLParser  ({
// xs,
})

const document = parser.process (xml)

for (const element of document.detach ().children) {
  console.log (element.attributes)
}
const {XMLReader, XMLNode, XMLSchemata} = require ('xml-toolkit')

// const xs  = new XMLSchemata ('schema.xsd')

const records = new XMLReader ({
//xs,
  filterElements : 'Record', 
  map            : XMLNode.toObject ({})
}).process (xmlSource)

// ...then:
// await someLoader.load (records)

// ...or
// for await (const record of records) { // pull parser mode

// ...or
// records.on ('error', e => console.log (e))
// records.pipe (nextStream)

// ...or
// records.on ('error', e => console.log (e))
// records.on ('data', record => doSomethingWith (record))
const {XMLReader, XMLNode} = require ('xml-toolkit')

const data = await new XMLReader ({
  filterElements : 'MyElementName', 
  map            : XMLNode.toObject ({})
}).process (xmlSource).findFirst ()
const {XMLParser} = require ('xml-toolkit')
xml = new XMLParser ()
  .process (fs.readFileSync ('doc.xml'))
  .toString ({
//  decl: {encoding: 'UTF-8', standalone: 1},
    space: '\t', 
//  attrSpace: 2, 
//  EOL: '\n',
//  level: 0, 
//  encodeLineBreaks: false,
   })
const {XMLReader} = require ('xml-toolkit')

let xmlResult = ''; for await (const node of new XMLReader ().process (xmlSource)) xmlResult += 
    node.isCharacters && node.parent.localName === 'ThePlaceHolder' ? id : 
    node.xml
const data = {ExportDebtRequestsResponse: {	
  "request-data": {
   // ...
  }
}

const xs = new XMLSchemata ('xs.xsd')

const xml = xs.stringify (data)

/* result:
<ns0:ExportDebtRequestsResponse xmlns:ns0="urn:...">
  <ns0:request-data>
    <!-- ... and so on ... -->
*/
const http = require ('http')
const {SOAP11} = require ('xml-toolkit')

const soap = new SOAP11 ('their.wsdl')

const {method, headers, body} = soap.http ({RequestElementNameOfTheirs: {amount: '0.01'}})

const rq = http.request (endpointURL, {method, headers})
rq.write (body)

Motivation

Unlike Java (with JAXB and JAX-WS) 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.

It might be a binding of a well known external library (libxml comes to mind first — as it's built in PostgreSQL in many popular distros, for example), but, alas, nothing viable of this sort seem to be available.

Pure 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:

  • minimum computing resources;
  • minimum lines of application code;
  • minimum external dependencies.

Limitations

No 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 may crash the local XML parser.

The XMLSchema is fairly usable for most real world cases, still some features (like xs:unique) are ignored completely, some others may require more test coverage. In general, XML Schema support in xml-toolkit should be considered forever beta.

There are perfectly reliable external tools for XML validation: for instance, xmllint (used in the test suite here) do just fine.