Mega Code Archive

 
Categories / C# / XML
 

Gets the XmlDocument to which this node belongs

using System; using System.IO; using System.Xml; public class Sample {   public static void Main()   {     XmlDocument doc = new XmlDocument();     doc.LoadXml("<book genre='novel' ISBN='1-111111-11-1'>" +                 "<title>C#</title>" +                 "</book>");     XmlElement root = doc.DocumentElement;     // Create a new element.     XmlElement elem = doc.CreateElement("price");     elem.InnerText="19.95";     Console.WriteLine(elem.OwnerDocument.OuterXml);     // Add the new element into the document.     root.AppendChild(elem);     Console.WriteLine(doc.InnerXml);   } }