如何识别XML文档中的更改 [英] How to identify changes in XML document

查看:58
本文介绍了如何识别XML文档中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Developer,

我有一个xml文档,我想查看用户所做的所有更改(例如更新标签,删除标签或记录).
有什么主意吗?

谢谢.

Hello Developer,

I have a xml document and i want to see all changes made by user( like update tag,delete tag or record).
Any idea?

Thank you.

推荐答案

当然可以,但是整个想法看起来是错误的:您需要跟踪数据的变化,而不是像XML这样的持久表示形式.如果比较XML本身,则您的方法已经错误.您还需要考虑到:您可以使用逻辑结构相同的物理上不同的XML内容.这样,即使是比较XML,也始终需要加载XML和比较数据.例如,您也可以分层比较DOM实例.

XML可以是数据的序列化形式.在这种情况下,您需要比较其内存形式的数据.您的比较取决于数据;通常,比较函数可以是一种或所有数据类或结构的方法.

同样,仅需要比较XML的事实表明您没有使用集中式方法来处理数据. 比较"数据的最佳方法是在执行修改时检测到更改.

—SA
Of course you can do it, but the whole idea looks wrong: you need to track changes in data, not in its persistent presentation like XML. If you compare XML itself, your approach is already wrong. You also need to take into account: you can have physically different XML content with identical logical structure. This way, even for comparison of XMLs, you always need to load XML and compare data. For example, you can hierarchically compared too instances of DOM.

XML can be a serialized form of data. In this case, you need to compare the data in its memory form. Your comparison depends on data; normally, the comparison function could be a method of one or all of data classes or structures.

Again, the mere fact that you need to compare XML suggests that you do not use the centralized approach do data. The best way to "compare" data is to detect the change at the moment the modification is performed.

—SA


这篇关于如何识别XML文档中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆