score:6

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.

score:8

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.

score:8

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


Related Articles