What's the difference between XElement and XDocument?

Posted by Kundan64 under XML on 1/10/2013 | Points: 10 | Views : 5835 | Status : [Member] | Replies : 3
What's the difference between XElement and XDocument?




Responses

Posted by: muralikrishnasurap-12704 on: 1/10/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Kundan64,
XDocument represents a whole XML Document which contains n number of Elements,where as XElement refers to an XMlElelemt in XMLDocument which contains some attributes and child elements.

Best Regards
Murali Krishna.S

Kundan64, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 1/11/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi kundan ,

Xdocument is a whole xml document , i.e when we need to read the xml from some source then will use the xdocument .
when we want to apply projections,filters on the xml file then we will use Xelements

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Kundan64, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubh on: 1/11/2013 [Member] Starter | Points: 25

Up
0
Down
Hi friend

6 down vote accepted


XDocument represents a whole XML document. It is normally composed of a number of elements.

XElement represents an XML element (with attributes, children etc). It is part of a larger document.

Use XDocument when working with a whole XML document, XElement when working with an XML element.

For example - XElement has a HasAttributes property indicating whether any attributes exist on the element, but an XDocument doesn't, as such a property is meaningless in the context of a whole XML Document.

i think its helps you

Shubham Agrahari

Kundan64, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response