Yes, it still loads the contents of the entire file into a view in memory. This is less useful than the XElement.Load(XmlReader) method, which can be really useful for loading only part of a document into memory at a time.
I would consider the XDocument.Load(XmlReader) method, as usually present for consistency, but I could see that it is useful in cases where other APIs provide the XmlReader , rather than the raw data. For example, you may have some data structure that provides "fake" XML access, allowing you to create an XmlReader . This way, he will never need to serialize real XML, which then needs to be parsed.
Another use case is that you want to use some aspects of XmlReadSettings that are not available in LoadOptions , such as ignoring comments or using a specific name table.
But no, you should not use XDocument.Load(XmlReader) if you are worried that the document does not fit into memory.
source share