all groups > dotnet xml > august 2006 >
You're in the

dotnet xml

group:

Merging XML documents



Merging XML documents Garikayi Mukombachoto
8/31/2006 12:00:00 AM
dotnet xml: Hi

I would really appreciate any assistanance with the following situation.

Lets say i have 2+ documents A,B,...n that i need to merge together, such
that the resulting documents contains totals or sum of the common elements.

For example:

Doc A

<employees>
<emp ID="1" Items="20">emp 1 name</emp>
<emp ID="2" Items="15">emp 2 name</emp>
<emp ID="3" Items="5">emp 3 name</emp>
</employees>

Doc B
<employees>
<emp ID="1" Items="15">emp 1 name</emp>
<emp ID="2" Items="5">emp 2 name</emp>
<emp ID="5" Items="55">emp 5 name</emp>
</employees>

Doc A + Doc B
<employees>
<emp ID="1" Items="35">emp 1 name</emp>
<emp ID="2" Items="20">emp 2 name</emp>
<emp ID="3" Items="5">emp 3 name</emp>
<emp ID="3" Items="55">emp 3 name</emp>
</employees>

How may i best go about this?, considering perfomance as well.

Thank you in advance.

RE: Merging XML documents Chakravarthy
8/31/2006 9:36:02 AM
Here pl confirm the 2 things..
1) Do you want only the attribute "ID" to be compared or
2) Once ID is compared, you wanted to add the "Items" attribute and remove
the extra element in the resulted doc....

Correct me if i'm mistaken ..

--
Every thing is perfect, as long as you share!!!


[quoted text, click to view]
Re: Merging XML documents Garikayi Mukombachoto
8/31/2006 5:53:39 PM
I want to compare the id and add the attributes. the resultant document
should contain names from both documents. Nothing is to be removed.

[quoted text, click to view]

AddThis Social Bookmark Button