expat-wasm

Evented parser based on a WASM-compiled version of expat

Usage no npm install needed!

<script type="module">
  import expatWasm from 'https://cdn.skypack.dev/expat-wasm';
</script>

README

An XML parser based on expat.

The approach taken here was to compile to WASM with emscripten, and ship the WASM binary in the NPM package. This means you get a real, battle-tested XML parser, with 0 runtime dependencies.

To install:

npm install --save expat-wasm

To use:

const XmlParser = require('expat-wasm')
async function f () {
  let p = await XmlParser.create()
  p.on('startElement', (name, attributes) => ...)
  p.parse('<foo/>')
}
f()

There are docs.

Requires nodejs 9 or higher (WASM!), and works in a browser using WebPack. See the webpack-demo directory for an example.

Build Status Coverage Status