xml.xmldocument.load does it load document to memory?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am making a simple app that groups files together by storing them into an xml document. But here is my concern. The xml file that is being loaded could be a gigabyte in size or it could just be 100k. So my question is that if I use the xml.xmldocument.load method does the data in that document get loaded into memory or does it stay on disk until you navigate down the nodes hiarchy

Here is a simple exampl

Dim x As New Xml.XmlDocument(
x.Load("test.xml"
MsgBox(x.DocumentElement.ChildNodes(0).ChildNodes(0).InnerText
x = Nothin

Now from the above example does the xmldocuent object build/load the childnodes structure and load the corresponding xml data into those nodes (IE: into memory) or when I type x.DocumentElement.ChildNodes(0).ChildNodes(0).InnerText) is it retrieving the xml data directly from the xml file itself

Again my only concern is that if I do this x.Load("test.xml") and the test.xml file is a gig in size for example, im afraid the app will throw an exception
 
I am making a simple app that groups files together by storing them into
an xml document. But here is my concern. The xml file that is being loaded
could be a gigabyte in size or it could just be 100k. So my question is that
if I use the xml.xmldocument.load method does the data in that document get
loaded into memory or does it stay on disk until you navigate down the nodes
hiarchy?

It gets loaded into memory COMPLETE in an in-memory tree representation, so
it's not suitable to handling very large files unless you have a LOT of
memory (this is not specifically a .NET problem, it is an issue with how the
DOM is supposed to work in general).

If you want your processing to be much more scalable, use the XmlReader
derived classes instead of loading it into the DOM (granted, it means more
work and will imply you can't do certain things... like XSLT
transformations)
 
I was afraid of that, oh well back to parsing xml the hard way (xml
readers/writers) ...
 
Back
Top