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

Need to know what changes have been made.

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

In general, I had some idea:

What if we introduce an additional attribute, for example, ChangeType, which will be placed in the nodes above which there was some kind of manipulation?

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

Then the XML is sent to the server, the changes are registered, the attribute is deleted, and the deleted nodes are deleted.

  • If you use XElement , they have a Changed event, you can use it too. XmlElement seems to have no events of its own. But in any case, you should, yes, subscribe to the changes. XDocument does not store its change history (why does it need it?). - VladD
  • 2
    @VladD XmlDocument has events, they work for any node belonging to the document. - rdorn
  • @VladD and it’s just possible to build a logging system on them, but still a lot of manual work will remain. - rdorn
  • one
    And what is the ultimate goal of such logging? there is just one thought, but not the fact that it will suit you. - rdorn

1 answer 1

You can write with pens a function for comparison after the last save with the current version of XML that lies in the operatic. Just compare all the nodes =)

Or you take a library for processing XML like the same HTMLAgrilityPack and extend their standard methods with your "logging" of changes. If it is not there (I do not know).