0.1.5 • Published 2 years ago

simple-xml-merge v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Simple XML merge

Installation

#Installation
npm install simple-xml-merge

Usage

Basic example

import { mergeXml } from 'simple-xml-merge';

const xmlData1: string = ''; //read xml from fs/network/Buffer
const xmlData2: string = ''; //read xml from fs/network/Buffer
const mergedXml = mergeXml(xmlData1, xmlData2);

//Serialize and use
console.log(mergedXml.toString());

Example with node "name" comparator

import { mergeXml } from 'simple-xml-merge';

const xmlData1: string = ''; //read xml from fs/network/Buffer
const xmlData2: string = ''; //read xml from fs/network/Buffer
const mergedXml = mergeXml(xmlData1, xmlData2, (node1, node2) => node1.name === node2.name);

//Serialize and use
console.log(mergedXml.toString());

With comparator it's possible to define rules for nodes merge. For example, XMLs

<root>
  <test attr="value">
</root>

and

<root>
  <test attr="value2">
</root>

will be merged to:

<root>
  <test attr="value2">
</root>

Without comparator the full comparison (name, attributes) will be used and such merge result to:

<root>
  <test attr="value">
  <test attr="value2">
</root>
0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago