What’s the difference between XElement.Load and XDocument.Load?

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.

That being said however, for most simple cases you can use them interchangeably.

It is important to understand the subtle differences in querying between these two types and for more information on that I would recommend that you please read Querying an XDocument vs. Querying an XElement:

When you load a document via
XDocument.Load, you will notice
that you have to write queries
slightly differently than when you
load via XElement.Load.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)