性能:与的XDocument的XmlDocument [英] Performance: XDocument versus XmlDocument

查看:459
本文介绍了性能:与的XDocument的XmlDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我才知道有过这种类型的问题在这里提出的(特别是前 - 我认为这是两个对象的一个​​很好的说明)。我的问题是更多的全能表现。我有几个XML文档是向上的100 - 300 K的大小。我注意到,加载这个信息到的XDocument ,而不是的XmlDocument 对象时,有一定的滞后性。有这两个对象之间存在严重的性能差异?难道他们访问XML不同的内容?当一个XML字符串,这是preferred,还是有区别的工作。最终利用这些对象是运行的查询(的XPath 或LINQ,视)所讨论的对象。

Now, I realize that there have been this type of question posed here before (especially this - which I think is a very good description of the two objects). My question is more around performance. I've got several XML documents that are upwards of 100 - 300 K in size. I've noticed that there is some lag when loading this information into an XDocument rather than an XmlDocument object. Is there a serious performance difference between these two objects? Do they access the content of the XML differently? When working with a string of XML, which is preferred, or is there a difference. The end use of these object is to run queries (XPath or LINQ, depending) on the object in question.

再次,这是主要的性能的问题,涉及到两个存储器和速度。

Again, this is primarily a question of performance, relating to both memory and speed.

推荐答案

XmlDocument的是文档对象模型的一个纯粹的管理实行。没有与任何COM组件,如MSXML库中没有互操作。任何的要求,否则完全是伪造的。整个XLINQ组API来了大约一个友好的方式与XML与.NET Framework中引入LINQ的互动。

XmlDocument is a purely managed implemenation of the Document Object Model. There is no interop with any COM components, such as the MSXML library. Any claim otherwise is completely bogus. The entire XLinq set of APIs came about as a friendlier way to interact with XML with introduction of LINQ in the .NET Framework.

如果你想最大限度地提高性能和舒适使用XPath,请尝试使用XmlDocument的使用编译XPath的EX pressions 的。

If you're trying to maximize performance and are comfortable using XPath, try using the XmlDocument and using compiled XPath expressions.

这篇关于性能:与的XDocument的XmlDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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