Mega Code Archive

 
Categories / C# / XML LINQ
 

Creates an XmlReader for this node

using System; using System.IO; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XDocument xmlTree = new XDocument(             new XElement("Root",                 new XAttribute("Att1", "Attribute Content"),                 new XElement("A1", 1),                 new XElement("A2", 2)             )         );         XmlReader reader = xmlTree.CreateReader();         reader.MoveToContent();         XmlDocument doc = new XmlDocument();         XmlNode cd = doc.ReadNode(reader);         doc.AppendChild(cd);         Console.WriteLine(doc.OuterXml);    } }