MergeXML merges the XML sources (files, strings, objects) into single DOM XML object. The merging is performed recursively on the node level adding new elements and replacing existing ones. The nodes with the same path/name are replaced/added sequentially and the modification can be controlled by the options.
MergeXML could be useful in cases where it is necessary to gather XML data from multiple sources. For example, to join the configuration files of different subsystems depending on the system operation.
var MergeXML = require('mergexml');
MergeXML can included as a global script or with
npm install mergexml --save and loaded as shown above.
var oMX = new MergeXML([opts]);
opts - the options object:
elem - FileList element of the XML file
source - XML string or DOM object
The methods merge a sequent source and return the final object or false if failed (see error property below).
You can search in the result object:
expr - XPath query expression
You can get the XML result tree:
The result object can be accessed also via oMX.dom property. The properties available:
The sources must have the same default namespace (if have at all). Prefix '_' is reserved to handle default namespace. IE doesn't allow replacement of the root node attributes.
The following files are included:
The MergeXML is realized also in PHP (see github.com).
To run the tests:
October 2016 (Martijn van de Rijdt)