Sreedevi
Sreedevi

Reputation: 9

Will xmlDocument.Load be overloaded if the input xml is over 100MB?

We are using a tool that takes an XML file as input and converts it to CSV. The tool is working fine for a 50MB file, but throwing an exception for a 100MB file.

After analysis I found that the xmlDocument.Load function is overloaded with the input. Can you please suggest any way to deal with the errors?

Upvotes: 0

Views: 83

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48250

The XmlDocument loads the whole document to memory and builds a DOM tree of it. Thus, it throws OutOfMemoryException for large files.

Instead you could use the XmlTextReader which reads the document token-by-token. It requires some code to handle the structure of the XML data but using this approach you can read arbitrarily large documents without issues.

Upvotes: 3

Related Questions