Accepted answer

By design, the difference (in usage) is very small.

You sometimes need a full XDocument, if you want access to the processing instructions etc.

But the following is fine (for most purposes):

XElement doc = XElement.Load("file.xml");

While a similar construct with XmlElement would not work.


The difference is that an XElement type represents an XML fragment while the XDocument type represents an entire XML document with all associated meta-data.


XDocument has a Declaration, Root while XElement is a single node.

Related Query