Difference between XElement and XDocument

Possible duplicate:
What is the difference between XElement and XDocument?

What is the difference between XElementandXDocument

+3
source share
3 answers

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

Sometimes you need a full XDocument if you want to access processing instructions, etc.

But in order (for most purposes):

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

Although a similar design with XmlElement does not work.

+6
source

The difference is that the type XElementrepresents an XML fragment, and the type XDocumentrepresents the entire XML document with all associated metadata.

+8
source

XDocument Declaration, Root XElement node.

+8

Source: https://habr.com/ru/post/1783386/


All Articles