in3xu4
in3xu4

Reputation: 978

XPathDocument vs. XmlDocument

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 :

Anyway, 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 want to implement the best possible solution here.

Upvotes: 9

Views: 10295

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

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.

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.

Upvotes: 7

Related Questions