If i am having the "comment 1", "comment 2" present in the xml and needs to have the xml merge having the comments as well and having 200+ files . The details as below:
Sample File 1:
<!--- Comment 1 -->
<root>
<element> text= "textA" >
<element1> textB= "textB" >
<!--- Comment 2 -->
<elements textC= "textC" >
</elements>
<!--- Comment 3 -->
<elements textD= "textD" >
</elements>
<!--- Comment 4 -->
<elements textE= "textE" >
</elements>
</element1>
</element>
</root>
Sample File 2:
<!--- Comment 1 -->
<root>
<element> text= "textA1" >
<element1> textB= "textB" >
<!--- Comment 2 -->
<elements textF= "textF" >
</elements>
<!--- Comment 3 -->
<elements textG= "textF" >
</elements>
<!--- Comment 4 -->
<elements textH= "textG" >
</elements>
</element1>
</element>
</root>
What I Want:
<!--- Comment 1 -->
<root>
<element> text= "textA1" >
<element1> textB= "textB" >
<!--- Comment 2 -->
<elements textC= "textC" >
</elements>
<!--- Comment 3 -->
<elements textD= "textD" >
</elements>
<!--- Comment 4 -->
<elements textE= "textE" >
</elements>
<!--- Comment 2 -->
<elements textF= "textF" >
</elements>
<!--- Comment 3 -->
<elements textG= "textF" >
</elements>
<!--- Comment 4 -->
<elements textH= "textG" >
</elements>
</element1>
</element>
</root>
Please suggest.
I tried following but no success
Merge xml files with nested elements without external libraries
But this will not include the comments.