c# – Is it possible to find out which nodes have been removed, which have been added, and which have changed in XML?

Question:

There is some XML, it changes in the course of its existence.

You need to find out what changes have been made.

Nowhere in XML objects is this information written or similar information can I get if I log by hand by subscribing to events?

In general, I got some idea:

What if we introduce an additional attribute, for example ChangeType, which will be applied to the nodes over which some manipulation took place?

Let's say the client deleted a node, but in fact he did not leave, but was marked with a special. value, changed some node and a corresponding mark appeared, added another mark to the node.

The XML is then sent to the server, the changes are logged, the attribute is removed, and the remote nodes are removed.

Answer:

You can write with handles a function to compare after the last save with the current version of XML, which is in operation. You just compare all the nodes =)

Or you take a library for processing XML like HTMLAgrilityPack and extend their standard methods with your own "logging" of changes. If it's not there (I don't know).

Scroll to Top