Skip to content

Instantly share code, notes, and snippets.

@mulderp mulderp/gist:8007500
Created Dec 17, 2013

Embed
What would you like to do?
var fs = require("fs");
var stream = fs.createReadStream("test.xml", {encoding: "UTF-8"});
var out = fs.createWriteStream("out.json", {encoding: "UTF-8"});
var sax = require("sax");
var parser = sax.createStream(true);
parser.on("opentag", function (node) {
console.log(node.name);
out.write("\n");
})
parser.on("text", function (node) {
out.write(JSON.stringify(node));
console.log(" " + node);
out.write("\n");
})
stream.pipe(parser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.