Reputation: 21260
Is there some simple way to convert XmlElement
to string
?
Upvotes: 29
Views: 40676
Reputation: 60193
Let's say you have this XmlElement
:
<node>
Hello
<effect color="pink">
World
</effect>
</node>
With Console.Write(xmlElement.Inner)
you see the inside of your node:
Hello <effect color="pink">World</effect>
With Console.Write(xmlElement.Outer)
you get everything:
<node>Hello <effect color="pink">World</effect></node>
With Console.Write(xmlElement.Value)
you get nothing, because Value always returns null for an XML element.
Upvotes: 4
Reputation: 700152
This will get the content of the element if the content is text:
element.Value
This will get the content of the element as XML:
element.InnerXml
This will get the element and its content as XML
element.OuterXml
Upvotes: 56