Working with XML: XmlReader, LINQ to XML, XmlSerializer and Secure Defaults
Hybrid reading, where XmlReader walks a large XML file and turns each document into a short-lived XElement, combines the convenience of LINQ to XML with constant memory: on a 267 MB file XDocument used a 703 MB heap, the hybrid approach 8.5 MB. With a UBL-like Bookstore invoice we cover namespaces, XSD validation, XmlSerializer versus DataContractSerializer, XmlSerializer's uncached constructors and .NET's defaults against XXE.
14 Nov 2026
·
14 min
·
2