/saxen/
parser
A tiny, super fast, namespace aware sax-style XML parser written in plain JavaScript.
Features
- (optional) entity decoding and attribute parsing
- (optional) namespace aware
- element / attribute normalization in namespaced mode
- tiny (<
5Kb
minified + gzipped)
Usage
var Parser = require('saxen');
var parser = new Parser();
parser.ns({
'http://foo': 'foo',
'bar': 'http://bar'
});
parser.on('startNode', function(elementName, getAttrs, decodeEntity, isClosing, getContext) {
elementName;
var attrs = getAttrs();
});
parser.on('endNode', function(elementName, decodeEntity, isOpening, getContext) {
...
});
parser.on('error', function(err, getContext) {
});
parser.parse('<blub xmlns="http://foo" />');
Credits
This library builds on the awesome work done by easysax and adds anonymous namespace handling and an object mode.
It is named after Sachsen, a federal state of Germany. So geht sächsisch!
LICENSE
MIT