序列化C#对象到XML

序列化C#对象到XML

本文介绍了序列化C#对象到XML - 最快的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经是序列化的C#对象到XML文件的应用程序。我目前使用.net XmlSerializer的。

I've an application that serialize c# objects to xml file. I'm currently using the .Net XmlSerializer.

我有,问题是,我需要序列〜8000主要节点(每个时间4-10子节点),以及它需要我目前有点像15 - 20分钟给他们所有的序列化。

The problem I've, is that I need to serialize ~8000 main nodes(with 4-10 subnodes each time), and it takes me currently something like 15-20min to serialize them all.

我已经保持相同的XML输出​​,因为该文件是由另一程序比我看完了,我不能让他们改变他们读取文件的方式。

I've to keep the same XML output, because the file are read by another program than mine, and I cannot make them change the way they read the file.

我做了一些搜索,我发现了很多比较,但它们都涉及使用protobuf网,其中有一个二进制序列化。

I've made some search, and I found a lot of comparison, but they all involve to use protobuf-net, which has a binary serialization.

所以我的问题是:我怎样才能改善这种序列化的时间?另一种串行?增加更多的属性我的模型(目前我只有XmlName,相同的列表)。

So my question is: how can I improve this serialization time? Another serializer? Adding more attributes to my model(currently I've only XmlName, same for lists).

感谢您!

推荐答案

看一看下面的链接也有一些技巧,以提高XML序列化性能

Have a look at the below link there are few tips to improve XML serialization performance

http://msdn.microsoft.com/en-us/library/ ff650685.aspx

如果它有可能为你改变你的组件的逻辑,我会用一个数据库来存储这么大的XML序列化尚未作出存储非常大的XML文件

If it is possible for you to change the logic of your component I would use a database to store such a big XML as serialization has not been made to store very large XML file

这篇关于序列化C#对象到XML - 最快的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:33