Large XML documents present a problem when they need to be transformed into other formats using XSLT or filtered using the XmlDocument class. This is due to the document being loaded into memory.
Fortunately, the .NET platform provides a robust set of classes that can be used to accomplish just about any task. In cases where large XML documents need specific nodes filtered out, the XmlTextWriter can be used along with the XmlTextReader to perform the filtering operation quickly and efficiently without consuming a large amount of memory. This example shows how this is accomplished by using the WriteNode() method of the XmlTextWriter. By using the technique shown, large XML documents can be pre-processed before an XSLT transformation so that the impact on memory is minimized.
|