Streaming XML parser and formatter
Last updated a year ago by t1st3 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install muxml 
SYNC missed versions from official npm registry.

muxml Build Status Travis Coverage Status

Streaming XML parser and formatter

muxml is a Transform stream that accepts XML strings, and emits small chunks containing individual XML elements.

The parser part of this module is built on sax:saxophone:. On parsing, the stream is broken-up and reassembled so that each opening/closing tag and each text is a chunk. During this process, sax events are re-emitted and are listenable down the pipeline.

Once XML is parsed, this module can optionally format XML in the following fashions:

  • XML minification (de-indentation and removal of newlines)
  • XML beautification (indentation and usage of newlines)
  • striping of comments
  • striping of CDATA
  • striping of instruction (like <?xml foo="blerg" ?>) tags
  • striping of <!DOCTYPE declarations
  • striping of attributes
  • tag filtering based on tag name

muxml is written with ES6/ES2015 syntax, although it is also shipped as an ES5 module with UMD syntax, meaning it can also be used:

  • in Node.js >= 4
  • in the browser, as global script
  • in the browser, with an AMD loader

Also available as a gulp / Grunt plugin, or as a CLI app.


$ npm install --save muxml


Suppose a file named example.xml containing the follwing XML

<a id="foo">

then, muxml() returns a transform stream that accepts XML strings and emits XML elements as strings

const muxml = require('muxml');

  .pipe(muxml({pretty: false}))
  .on('data', function (data) {
    //=> '<b><c>d</c></b>'



Type: boolean
Default: true

Set sax parser strict argument


Type: boolean
Default: true

Prettify the output. If true, output has newlines and indentation.


Type: string
Default: spaces

When pretty is set to true, indent with either spaces or tabs.


Type: integer
Default: 2

When pretty is set to true and indentStyle is set to spaces, then indent with this number of spaces.


Type: integer
Default: 1

When pretty is set to true and indentStyle is set to tabs, then indent with this number of tabs.


Type: string
Default: null
a filter for tag names

Filter XML with tags with name matching the filter.


Type: boolean
Default: false

Strip attributes from tags.


Type: boolean
Default: true

Strip CDATA tags.


Type: boolean
Default: true

Strip XML comments.


Type: boolean
Default: true

Strip <!DOCTYPE declarations.


Type: boolean
Default: true

Strip processing instruction (like <?xml foo="blerg" ?>) tags.


Type: object
Default: {}

Set options of sax parser. Note that trim can not be set to false.




Type: object
as described above



MIT © t1st3

Current Tags

  • 2.0.1                                ...           latest (a year ago)

11 Versions

  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           2 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (6)

Copyright 2014 - 2016 © |