.netperformancelinq-to-xmlxmltextreader

Performance: XmlTextReader vs LINQ to XML


I'm about to read some XML (who isn't :-)). This time however it's a lot of data: about 30,000 records with 5 properties, all in one file.

Till now I've always read that the XmlTextReader is the fastest way to read XML data, but now there also is the (nice syntax of) LINQ to XML.

Does anybody know any performance issues, or that there aren't any, with LINQ to XML?

Michel


Solution

  • The API supplied by LINQ to XML is much nicer than the low level API of the XmlTextReader. This will result in code that is much more maintainable. As Mitch Wheat already said, 30,000 records is not that much. IMO you should just use LINQ to XML and only when you notice LINQ to XML is too slow, fallback to using the XmlTextReader directly.