Fusion XML

Use case: You have two xml files and you want to merge them into one. The tool will merge the two files and keep the order of the elements.

console screenshot

You can use it to merge two xml files that have the same structure but different content. And could use a filter to select the elements and his children that you want to merge.

Example of use: fusion_xml.exe -id filter inputA inputB -id

fusion_xml.exe -id ROOT ..\..\sample1.xml ..\..\sample2.xml

Produces the output:

<ROOT ver="1.0" id="0101" code="beta">
        <A/>
        <A/>
        <B/>
        <B attr="at"/>
        <C>
                <CA/>
                <CB/>
        </C>
        <C attr="at"/>
        <D>
                <DA/>
                <DB/>
                <DC/>
        </D>
        <F id="0101">
                <FA id="0101" attr="at" otherAttr="bt"/>
                <FB>
                        <FBA/>
                </FB>
                <FB/>
        </F>
        <F id="0101">
                <FA id="0101" attr="at" otherAttr="bt"/>
                <FB/>
                <FB>
                        <FBA/>
                </FB>
        </F>
        <G/>
        <E/>
</ROOT>

Where the content of sample1.xml is:

<ROOT ver="1.0" id="0101" code="beta">
	<A/>
	<B/>
	<C>
		<CA/>
		<CB/>
	</C>
	<D>
		<DA/>
		<DB/>
		<DC/>
	</D>
	<F id="0101">
		<FA id="0101" attr="at" otherAttr="bt"/>
		<FB>
			<FBA/>
		</FB>
		<FB/>
	</F>
	<G/>
</ROOT>

And the content of sample2.xml is:

<ROOT ver="1.0" id="0101" code="beta">
	<A/>
	<B attr="at"/>
	<C attr="at"/>
	<F id="0101">
		<FA id="0101" attr="at" otherAttr="bt"/>
		<FB/>
		<FB>
			<FBA/>
		</FB>
	</F>
	<E/>
</ROOT>

Source at https://github.com/jsonzilla/fusion_xml

Posted on:
January 22, 2021
Length:
1 minute read, 190 words
See Also: