xml-compare.js
v0.2.0
Published
Compare XML streams
Readme
xml-compare.js
Compare xml streams
A performant XML stream comparator
CLI Usage
xml-compare expected.xml < actual.xml
API
var fs = require('fs'),
XmlCompare = require('./xml-compare');
var exectedFile = ...
var actualFile = ...
var expectedStream = fs.createReadStream(expectedFile);
var actualStream = fs.createReadStream(expectedFile);
XmlCompare.compare(expectedStream, actualStream)
.on('same', function(expected, actual) { ... })
.on('differ', function (err, expected, actual) { ... })
.on ('end', function () { ...})
Events
same
expectedEventactualEvent
differ
errError messageexpectedEventactualEvent
end
Where the Event object holds
Event.eventEvent type ∈ {'startElement', 'endElement', 'text' }Event.argsArray of event data
Either one of end or differ will be emitted indicating the termination of the process.
XPath-like difference logging
XmlCompare.comparePretty(expectedStream, actualStream)
.on(...);then differ events will be also logged to the console as diffed XPath-like text
Install
npm i -g xml-compare.js
LICENSE
MIT
