XDocument Class represents an XML document.
using System; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{ public static void Main(){ XDocument srcTree = new XDocument( new XComment("This is a comment"), new XElement("Root", new XElement("Child1", "data1"), new XElement("Info1", "info1") ) ); XDocument doc = new XDocument( new XComment("This is a comment"), new XElement("Root", from el in srcTree.Element("Root").Elements() where ((string)el).StartsWith("data") select el ) ); Console.WriteLine(doc); } }