0

I have very large XML files (> 2GB) and if I just try to use XmlDocument.Load() I get an OutOfMemory exception. I want to read the high-level elements in the XML via an XmlTextReader and then use XPath on each high-level element, without having to load the entire XML document into a huge XMLDocument object.

So, for example, if I have an XML file with...

<xmlStuff>
  <foo>
    <name>Bob Builder</name>
    <age>23</age>
  </foo>
  <foo>
    <name>Steve Austin</name>
    <age>99</age>
  </foo>
</xmlStuff>

And I am reading the XML file with XmlTextReader (because the file is so large) once I find a element I want to load just that 1 element into an XmlElement so I can then parse it via XPath.

Is there a better way to approach this? Can I just perform XPath through an XmlReader or XmlTextReader?

shodson
  • 55
  • 7

1 Answers1

0

Take a look at saxparser equivalent in c# and the article it points to.

Community
  • 1
  • 1
Dweeberly
  • 4,668
  • 2
  • 22
  • 41