saxml

Simple API for XML

Usage no npm install needed!

<script type="module">
  import saxml from 'https://cdn.skypack.dev/saxml';
</script>

README

saxml

Build Status npm version

Simple API for XML in JavaScript.

Usage

let Saxml = require('saxml')
let saxml = new Saxml(strict, options)

saxml.on("error", function (e) {
  console.error("error!", e)

  // clear the error and resume
  this._parser.error = null
  this.resume()
})
saxml.on("opentag", function (d) {
  // process data.
})

fs.createReadStream("foo.xml")
  .pipe(saxStream)

// Or using write and close methods.
// saxStream.write('<foo>bar</foo>').close()

Events

The event names can be exported through the constructor Saxml.

console.log(Saxml.events)

/* [
 *  "text",
 *  "processinginstruction",
 *  "sgmldeclaration",
 *  "doctype",
 *  "comment",
 *  "opentagstart",
 *  "attribute",
 *  "opentag",
 *  "closetag",
 *  "opencdata",
 *  "cdata",
 *  "closecdata",
 *  "error",
 *  "end",
 *  "ready",
 *  "script",
 *  "opennamespace",
 *  "closenamespace"
*/ ]