0

I have very huge XML files that i have to format. The files can be up to 10GB big.

I couldnt find any solution that doesnt include XDocument. XDocument loads the whole file into the RAM which obviously will be problematic with a 10GB file. Especially in 32 bit systems

Writing an XML formatter from scratch that works with a stream kind of feels like reinventing the wheel to me. I cant imagine me being the first person who had to work with something like this. If possible I would like to use an existing solution.

Does anyone know anything i can work with other than writing everything myself?

Thank you

  • .Net Framework 4.8
  • C#8
Yuion aro
  • 45
  • 4
  • 1
    Take a look a this [question](https://stackoverflow.com/questions/15772031/how-to-parse-very-huge-xml-files-in-c) it seems the solution offered there does not load the entire document into memory. – Harjan Feb 14 '20 at 13:21
  • Have you considered using XmlReader and XmlWrite in tandem to rewrite the file out via streaming? – TomTom Feb 14 '20 at 14:08
  • Use a combination of xmlReader and xml linq. See my answer at following posting : https://stackoverflow.com/questions/40456446/efficient-way-to-read-large-xml-into-dfferent-node-types-in-c-sharp – jdweng Feb 15 '20 at 09:18

1 Answers1

0

You can use the XmlReader class.
This class does not load the entire document into memory, as opposed to the XDocument implementation.

Harjan
  • 533
  • 1
  • 6
  • 24