Merging two XMLs

Simple merging

Sometimes we need to merge two partial XMLs:

Org:

New:

Output:

It is not always possible to do so without a schema, but we do the best that we can.

Why this comes about

We get only partial source data. Then, we only generate data that we want to update. The two sets of data are not proper subsets of each other.

The real solution is to define the full set of data, so we always generate the full set of data. This avoids all issues.

Be careful!

We have to be very careful about merging blindly because it will always use the superset. I introduced a bug this way — we can add, but not delete!