Is there a way to manage changes to an irregular X

2020-06-23 06:43发布

I'm looking for a way to import and export a list of changes to an XML data document (irregular structure; not naturally fitting a DataSet).

If I had a regular structure I would use a DataTable, and I could evaluate which records have been edited and then commit or cancel the changes, and I could also transmit a packet of the required changes.

How do I do this with XML data?

If a good answer isn't available I'm thinking my best bet would be to use a DataTable with the scheme [XPath, Value] despite the inefficient storage, and navigation difficulties.

I expect to make changes to the document (with XPath or LINQ or data-bound controls or whatever), then remember the changes and send only the changes over TCP.

Then I want to receive back another change list and apply it to the XML document. I don't want to send the entire document both for size and because I need to know and evaluate the changes being sent.

(Just to clarify: My program needs to send and receive document changes. The other end of the pipe is not based in .net, and is not part of this question.)

7条回答
地球回转人心会变
2楼-- · 2020-06-23 07:20

Do you need to act on this changes or just store them, if you want just to store the updated version you can use binary diff algorithms to pass the diffs between 2 xml files. And then to updated stored version with the difference. Good algorithm for this is bifdiff The C# version can be found here.

Another aproach is to use this XmlDiff class from MS

查看更多
登录 后发表回答