XPathDocument中主场迎战的XmlDocument [英] XPathDocument vs. XmlDocument

查看:117
本文介绍了XPathDocument中主场迎战的XmlDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发在ASP.NET博客引擎以及一个存储库实现使用XML文件作为数据存储。在XML存储库将主要用于当地使用和测试目的。现在,虽然它可能不是一个问题,其中有大量的可用内存和处理能力,今天的计算机,但无论如何,我想知道一些具体的细节:

I'm developing a blogging engine in ASP.NET and one the repositories is implemented to use XML files as the data store. the XML repository will mainly be used for local use and testing purposes. now although it might not be that of an issue with today's computers which have lots of memory available and processing power, but nevertheless i wanted to know some specific details :

  • 的XPathDocument是只读文件而XmlDocument的是一个读/写文件。所以,是的XPathDocument比XmlDocument的更加轻便,因为它缺乏写作能力。
  • 我确实知道,当你装入的XmlDocument加载整个文档中存储的XML文档,这可能是一个问题,如果文件大小大。并XPathDocument中做同样的事情?如果是的话,我怎么能读单个节点或一组从XML文档的节点不先加载整个文档中的记忆是什么?我知道我可以使用XmlTextReader的,但是这意味着我必须分析整个文档,我访问节点的顺序。我想能够查询XML文档的XPath EX pression。

不管怎么说,如果对象图的大小差异并不大(的XmlDocument和XPathDocument中),它不会伤害只是把工作做好,但我想在这里实现了最佳的解决方案。

Anyways, if the size of the object graphs don't differ much (XmlDocument and XPathDocument) it won't hurt to just get the job done, but i wanna implement the best possible solution here.

在此先感谢[:

推荐答案

XPathDocument中读取完整的文件到内存中的好,那是需要支持的所有的XPath轴像preceding同胞,preceding,祖先,父母,子女,后代,继同胞,以下。

XPathDocument reads the complete document into memory as well, that is needed to support all the XPath axes like preceding-sibling, preceding, ancestor, parent, child, descendant, following-sibling, following.

如果你想要做的XPath和XQuery查询,而无需加载整个文档到内存中,那么你必须寻找到专门的XML数据库或至少与使用XQuery支持XML数据类型的SQL数据库。 MS SQL服务器实例都有 XML数据类型,并支持一些(在我看来相当有限)该版本的XQuery。

If you want to do XPath or XQuery queries without loading the whole document into memory then you have to look into specialized XML databases or at least into SQL databases with an XML data type with XQuery support. MS SQL server for instance has an XML data type and supports some (in my view rather limited) version of XQuery on that.

这篇关于XPathDocument中主场迎战的XmlDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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