I\'ve not done much with linq to xml, but all the examples I\'ve seen load the entire XML document into memory.
What if the XML file is, say, 8GB, and you really don
Using XElement.Load
will load the whole file into the memory. Instead, use XmlReader
with the XNode.ReadFrom
function, where you can selectively load notes found by XmlReader
with XElement
for further processing, if you need to. MSDN has a very good example doing just that: http://msdn.microsoft.com/en-us/library/system.xml.linq.xnode.readfrom.aspx
If you just need to search the xml document, XmlReader
alone will suffice and will not load the whole document into the memory.