views:

33

answers:

1

I'm taking data from an XML file of records that I'm using System.Xml.Serialization.XmlSerializer to deserialize into strongly-typed data structures. Each record that I run through is getting converted to another format and written to another file. I dislike the idea of storing the whole XML file in memory without need, but it's not critical that I conserve the memory either. Is there a way I can rewrite to read in one record at a time?

+1  A: 

You can use Linq to XML to read each record. Then you can either bypass object creation and just convert the XML directly into the format you need or use the string to instatiate an XMLTextReader to read the xml. However the XMLTextReader "Represents a reader that provides fast, non-cached, forward-only access to XML data." So if you use it the whole XML is not in mememory, you can just use it directly, I think.

Wilhelm