Download convert xmlelement to string c# for windows 7

Convert xmlelement to string c#

Get via App Store Read this post in our app!

I need to convert an XML string into an XmlElement

I'm looking for the simplest way to convert a string containing valid XML into an XmlElement object in C#.

How can you turn this into an XmlElement ?

Beware!! If you need to add this element to another document first you need to Import it using ImportNode .

Suppose you already had a XmlDocument with children nodes, And you need add more child element from string.

(Or in case you're talking about XElement, use XDocument.Parse:)

You can use XmlDocument.LoadXml() to do this.

Here is a simple examle:

I tried with this snippet, Got the solution.

If any other better/ efficient way to implement the same, please let us know.

Convert xmlelement to string c#

Get via App Store Read this post in our app!

XmlElement to string conversion

Is there some simple way to convert XmlElement to string ?

This will get the content of the element if the content is text:

This will get the content of the element as XML:

This will get the element and its content as XML

You can look at the Value or InnerText properties of the element.

However, without further details of exactly what you are looking, I can't help more.

Seeing as you want the XML of all nodes, using InnerXml or OuterXml should do nicely.