Mega Code Archive

 
Categories / C# / XML
 

Gets or sets the concatenated values of the node and all its children

using System; using System.Xml; public class Test {   public static void Main() {     XmlDocument doc = new XmlDocument();     doc.LoadXml("<root>"+                 "<elem>some text<child/>more text</elem>" +                 "</root>");     XmlElement elem = (XmlElement)doc.DocumentElement.FirstChild;     Console.WriteLine( elem.InnerText );     Console.WriteLine(elem.InnerXml);     elem.InnerText = "Text containing <markup/> will have char(<) and char(>) escaped.";     Console.WriteLine( elem.OuterXml );     elem.InnerXml = "Text containing <markup/>.";     Console.WriteLine( elem.OuterXml );   } }