Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm's 300,000 packages pre-installed, including node-xml-compare with all npm packages installed. Try it out:

var nodeXmlCompare = require("node-xml-compare")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-xml-compare v0.1.0

To compare two xml strings and highlight the differences

node-xml-compare

xml compare is node.js package to compare two xml strings, and generate their differences as a html encoded string sothat it could be directly duped into a code block in an html page.

Description

xml compare is built on top of sax-js. sax-js.

Install

It can be installed via.

npm install node-xml-compare

Usage

To use this just pass the xml strings you want to compare into the xmlcompare variable.

var xmlcompare = require('node-xml-compare');

xml1 = "<sample><a>1</a><a>2</a><a>4</a><b>4</b></sample>";
xml2 = "<sample><a>2</a><a>1</a><a>3</a><c>3</c></sample>";

xmlcompare(xml1, xml2, function(result) {

    //render result[-] to html page to show the xml1 nodes that are not in xml2
    //render result[+] to html page to show the xml2 nodes that are not in xml1

});


Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free