4
I’d like to know the difference between Xmldocument and Xelement.
4
I’d like to know the difference between Xmldocument and Xelement.
3
XmlDocument
represents an entire XML document. It is possible to use this class to manipulate XML files.
XElement
is a class of System.Xml.Linq
, it is used to represent a single element within an XML document in the LINQ to XML.
You can use it to manipulate, get the value, remove, change the child elements of an element in an XML document.
Note that the class XmlDocument
is part of namespace System.Xml
while the class XElement
is part of the System.Xml.Linq
. In LINQ the class used to represent an XML document is the XDocument
.
Browser other questions tagged c# xml linq xmldocument
You are not signed in. Login or sign up in order to post.
and xmlElement is the same thing as Xelement ?
– Stand Alone
@Standalone I missed the writing. It’s clearer now?
– Jéf Bueno
I have an Xmldocument and need to pass a Xelement to a method, in case you said xelement is a single xmldocument element right? I can get a xelement from an xmldocument or it has nothing to do ?
– Stand Alone
@Standalone Todo
XmlDocument
has a property calledDocumentElement
, this property is of the typeXmlElement
and represents the root element of the XML document. Similarly, every instance ofXDocument
has a property calledRoot
of the kindXElement
which has the same purpose. Note thatXmlDocument
andXElement
are part of two distinct Apis.– Jéf Bueno