Reputation: 879
I have many xml files with different node structure and different nodes. Now I want to merge these two xml files in a single xml file. after searching , I found that i can use xslt for merging multiple xml files and every example is dealing with xml files having same nodal structure.
Thanks Stephen for your suggestions but i am facing different scenario. Following are the snippet of xml files which i want to merge together and also the final xml file should look like.
file1.xml
<Equipment>
<Items>
<Item>
<ID>_stdpart_38100</ID>
<Index>1</Index>
<SubcategoryIDRef>Power</SubcategoryIDRef>
</Item>
</Items>
<Subcategories>
<Subcategory>
<ID>Power</ID>
<CategoryIDRef>Power and Handling</CategoryIDRef>
</Subcategory>
<Categories>
<Category>
<ID>Power and Handling</ID>
<Title>Power and Handling</Title>
<Subtitle />
</Category>
<Categories>
</Equipment>
file2.xml
<Models>
<Model>
<ID>S Sedan</ID>
<Name>S Sedan</Name>
<Index>1</Index>
<Equipment>
<Item>
<IDRef>_stdpart_38100</IDRef>
<Optionality>S</Optionality>
</Item>
<Equipment>
</Model>
</Models>
and the final merged file should look like merged.xml
<Models>
<Model>
<ID>S Sedan</ID>
<Name>S Sedan</Name>
<Index>1</Index>
<Equipment>
<Item>
<ID>_stdpart_38100</ID>
<Index>1</Index>
<Subcategory>
<ID>Power</ID>
<Category>
<ID>Power and Handling</ID>
<Title>Power and Handling</Title>
<Subtitle />
</Category>
</Subcategory>
<Optionality>S</Optionality>
</Item>
</Equipment>
</Model>
</Models>
Upvotes: 0
Views: 2335
Reputation: 719551
I found that i can use xslt for merging multiple xml files and every example is dealing with xml files having same nodal structure.
Here is an example in which the XML files have radically different structure:
If this doesn't help, update your question with examples of your XML and what you need the merged file to look like.
Upvotes: 1