Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an XPathDocument load the whole xml document?

Tags:

c#

xml

xpath

If I do

XPathDocument doc = new XPathDocument("filename.xml");

Does that load the entire document into memory? I'm writing a mobile phone app and the document might store lots of data that doesn't ever need to all be loaded at the same time. Mobile phones don't usually have too much ram!

like image 342
Wires Avatar asked Apr 09 '10 18:04

Wires


1 Answers

Yes, the whole XML document is represented in memory.

One solution is to split a large XML document into many smaller ones.

Or, alternatively, you may write your own XmlReader that will ignore unwanted subtrees. You can pass this XmlReader as argument to the XpathDocument() constructor -- need to camouflage it as TextReader.

like image 62
Dimitre Novatchev Avatar answered Oct 08 '22 22:10

Dimitre Novatchev