Skip to content

Instantly share code, notes, and snippets.

@mape
Created May 27, 2010 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mape/415879 to your computer and use it in GitHub Desktop.
Save mape/415879 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
fs = require('fs');
var libxml = require('libxmljs');
fs.readFile('products.xml', function (err, data) {
var parser = new libxml.SaxParser(function(cb)
{
cb.onStartDocument(function()
{
sys.puts('STARTING');
});
cb.onEndDocument(function(xml) {
sys.puts(sys.inspect(xml));
sys.puts('ENDING');
});
});
// Parse a string:
parser.parseString(data.toString());
});
/*
OUTPUT:
STARTING
undefined
ENDING
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment