关于XML文件作为C#应用程序中的数据源 [英] About XML file as a datasource in the C# application

查看:93
本文介绍了关于XML文件作为C#应用程序中的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个使用xml文件作为数据源的应用程序.但我不知道xml文件使用的任何限制.

我想根据xml数据的大小了解xml文件的局限性.因为我曾在Google&上搜索过当xml数据大小超出限制时,我得到的结果像xml没什么用,那时候您的应用程序可能会显示诸如堆栈溢出"之类的错误.但我无法找到xml数据的限制.



有人可以帮我吗?

thanx ....

I have developed an application which uses xml file as a datasource . but i don''t know any limitations of the xml file usage.

I want to know the limitations of the xml file according to the size of the xml data. because i''d searched on google & i got result like xml is not useful when the xml data size is out of limit that time may be your application will show error like "stack overflow" . but i''m unable to finding that limit of the xml data.



can anybody help me?

thanx....

推荐答案

据我所知,任何地方都没有设置实际限制.可使用的限制取决于太多因素而难以轻松计算,其中包括树"的深度,系统内存和许多其他因素.

如果是我,我会设置一个应用程序,可以将给定数量的记录"(一次说1000或10000个)插入测试文件中,并继续尝试使用该文件,然后添加更多记录,直到应用程序变得无法使用,或者您收到StackOverflowException.返回上一步并将其视为最大大小.
As far as I know there is no actual limit set anywhere. The useable limit would depend on too many factors to be easily calculated and would include the depth of the ''tree'', system memory and many other factors.

If it were me I would set up an Application that could insert a given number of ''records'' (say 1000 or 10000 at a time) into a test file and keep trying to use that file, then adding more records, until your application becomes unusable or you get a StackOverflowException. Go back one step and regard that as the maximum size.


XML本身当然没有设置任何大小限制.但是,您的文件系统可能有文件大小限制.而且,如果您要处理XML文件,则需要注意,诸如System.Xml.XmlDocument或System.Xml.Linq.XDocument之类的API会构建完整XML文档的内存树模型,因此应用程序的内存消耗将随着您尝试处理的XML的大小而增长.因此,实际上,如果使用这些API,则应用程序有多少可用内存是有限制的.
另一方面,XmlReader只能转发,并且逐个节点拉入,这意味着内存消耗不会随XML文档的大小而增长.

我建议您以较小的块读取和处理它,以免它一次无法将整个内容加载到内存中.但是,如果您尝试将XML作为流写入最终输出.XML文件,则最好使用支持2 Gb以上的最新操作系统.但是,如果您有一个非常庞大的XML,您可能会考虑使用一个小型数据库.
XML itself certainly does not set any size limit. Your file system however might have a file size limit. And if you want to process your XML files then you need to be aware that APIs like System.Xml.XmlDocument or System.Xml.Linq.XDocument build an in-memory tree model of the complete XML document so the memory consumption of your application will grow with the size of the XML you are trying to process. So in practical terms there is a limit of how much memory your application has available, if you use those APIs.
XmlReader on the other hand works forwards only and pulls in node by node meaning that way the memory consumption does not grow with the size of the XML document.

My recommendation for you is to read and process it in smaller chunks, that it might not handle loading the entire thing into memory at one time. However, if you are trying to WRITE XML as a stream to a final output .XML file, you should be good to go on most current OS that support over 2 gig. But if you have a really huge XML, you might think of using a small database.


我发现,如前所述,树的复杂性可能会影响其大小. XML文件.

在实践中,我发现大型XML文件可能会导致StackOverflow异常.如果您正在处理大文件的一半,那么这可能是个大问题.

一种解决方案是将XML文件拆分为相等大小.反序列化它们时,可以根据该信息创建一个列表.

希望有帮助,

劳伦斯
I have found that, as previously stated, the complexity of the tree can have a bearing on the size of the XML file.

In practice I''ve found that large XML files can cause StackOverflow exceptions. This can be a big problem if you''re halfway through processing a large file.

One solution, is to split out your XML files into equal sizes. When de-serialising them it''s then possible to create a single list from that information.

Hope that helps,

Laurence


这篇关于关于XML文件作为C#应用程序中的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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