Siva
Siva

Reputation: 1861

How to load large XML in xmldocument in VB

Below is my code to load xml into xml document.

                filestream = File.OpenRead("Application Data\MSP\XMLDATA.XML")
                myXmlDoc = New XmlDocument
                myXmlDoc.Load(filestream)

But it throws out of memory exception. Is there is any way to load xml into xmldocument partially? or How can I solve this.

Upvotes: 0

Views: 292

Answers (1)

codeDom
codeDom

Reputation: 1769

Are you sure that the out of memory exception is because the document is large? This exception could be due to an error in the syntax of the document.

I mean that the error could be due to some problem reading the file rather than the size of the file itself. If the XML is poorly formed, maybe something is causing an infinite loop of lookups or something. 4.5 Meg isn't that big

Try to read the document with XmlReader.

Upvotes: 0

Related Questions