有没有一种方法来管理改变为不规则的XML文档一样有一个与数据表?不规则、方法来、有一个、数据表

2023-09-04 22:51:42 作者:獨占1朶\花//

我在寻找一种方式来导入和导出更改的XML数据文件的列表(不规则的结构,不能自然拟合数据集)。

如果我有一个规则的结构,我会用一个数据表,我可以评价该记录已经被编辑过,然后提交或取消的变化,我也可以传输的要求变化的数据包。

我如何做到这一点XML数据?

如果一个很好的答案不可我想我最好的选择是使用一个DataTable该计划[XPath的,值]尽管效率低下的存储和导航困难。

我希望更改文件(用XPath或LINQ或数据绑定控件或其他)的话,记得更改并通过TCP仅发送变化。

然后我想收回另一个变化列表,并将其应用到XML文档。我不想整个文档无论是规模和因为我需要了解和评估所发送的改变时发送。

(只是为了澄清:我的程序需要发送和接收文档更改管道的另一端不是基于.NET中,并且不是对这个问题的部分)

解决方案 你怎么想只发送变化? 请您预计每次许多变化或者只是轻微的变化? 你有什么样的变化考虑? 你们是不是要保持同一个文件的副本跨进程边界? 你将如何解决冲突的变化? 你要锁定的XML文档,直到更改传播? 都是独立的副本,或者一个是主副本? 查看数据结果

如果您使用XmlDocument的事件,如NodeInserted,NodeDeleted,NodeChanged你可以建立这样的变化的列表,然后执行它们的另一个副本。如果变化总量比文档本身,你可以改为发送文档长。正在压缩XML数据也有帮助。

以外,我没有看到任何其他简单的方法。

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.)

解决方案

How do you suppose to only send changes? Do you expect numerous changes or just slight changes every time? What kind of changes do you have to consider? Are you trying to maintain to copies of the same document across process boundaries? How are you going to resolve conflicting changes? Are you going to lock xml documents until changes are propagated? Are both copies independent, or one is master copy?

if you used XmlDocument events such as NodeInserted, NodeDeleted, NodeChanged you could build a list of such changes and then execute them on another copy. If total amount of changes is longer than document itself you could send document instead. Zipping xml data also helps.

other than that I do not see any other easy approach.