convert a subset of XML into JSON

npm install xml-the-good-parts
7 downloads in the last week
10 downloads in the last month


Convert a subset of XML into JSON.

If you have tidy XML that has tags but no attributes, then with this module you can convert it into JSON.

If someplace it has more complex stuff, it'll probably barf. NO WARRANTY EXPRESSED OR IMPLIED

Example - convert to json

var XMLTGP = require('xml-the-good-parts')
var JSONStream = require('JSONStream')

var XMLTGP     = require('../')
var through    = require('through')

  .pipe(through(function (node) {
    if(node.tag = 'a' && node.attrs.href)
      this.queue(node.attrs.href + '\n')

or as cli tool.

npm install -g xml-the-good-parts

xml-the-good-parts < evil.xml > nice.json

Known Bugs/TODO

This does not support escaped quotes in attributes. Probably you should use sax or trumpet instead.



npm loves you