I wish to merge two XML files, similar to What is the fastest way to combine two xml files into one
but I cannot wrap my head around how to group and merge them based on of the node values (Configuration node's Domain node value) I am trying it with Linq, but it doesn't make it easier, even the group by and where clause is there.
Basically I wish all Component nodes (duplicates are allowed) to be listed under the same Configuration node, which Domain name node values are equal.
In other words with the below example: the result XML has two Configuration nodes, one with Domain: MyDom01 the other is Domain: MyDom02 and under each configuration I have one Components node with all the Component listed.
Is that even possible?
One.XML
<System>
<Configurations>
<Configuration>
<Domain>MyDom01</Domain>
<Components>
<Component>
<Name>Memory</Name>
<Size>16</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>8</Size>
</Component>
</Components>
</Configuration>
<Configuration>
<Domain>MyDom01</Domain>
<Components>
<Component>
<Name>HDD</Name>
<Size>1</Size>
</Component>
</Components>
</Configuration>
<Configuration>
<Domain>MyDom02</Domain>
<Components>
<Component>
<Name>CPU</Name>
<Size>12</Size>
</Component>
</Components>
</Configuration>
</Configurations>
</System>
Another.XML
<System>
<Configurations>
<Configuration>
<Domain>MyDom01</Domain>
<Components>
<Component>
<Name>Memory</Name>
<Size>128</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>32</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>32</Size>
</Component>
</Components>
</Configuration>
<Configuration>
<Domain>MyDom02</Domain>
<Components>
<Component>
<Name>Memory</Name>
<Size>32</Size>
</Component>
</Components>
</Configuration>
</Configurations>
</System>
Merged.XML:
<System>
<Configurations>
<Configuration>
<Domain>MyDom01</Domain>
<Components>
<Component>
<Name>Memory</Name>
<Size>16</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>8</Size>
</Component>
<Component>
<Name>HDD</Name>
<Size>1</Size>
</Component>
<Component>
<Name>Memory</Name>
<Size>128</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>32</Size>
</Component>
<Component>
<Name>CPU</Name>
<Size>32</Size>
</Component>
</Components>
</Configuration>
<Configuration>
<Domain>MyDom02</Domain>
<Components>
<Component>
<Name>CPU</Name>
<Size>12</Size>
</Component>
<Component>
<Name>Memory</Name>
<Size>32</Size>
</Component>
</Components>
</Configuration>
</Configurations>
</System>