Use Linq to create XElement
using System; using System.Text; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass { public static void Main() { StringBuilder output = new StringBuilder(); XElement xmlTree1 = new XElement("Root", new XElement("Child1", 1), new XElement("Child5", 5), new XElement("Child6", 6) ); XElement xmlTree2 = new XElement("Root", from el in xmlTree1.Elements() where ((int)el >= 3 && (int)el <= 5) select el ); output.Append(xmlTree2); Console.WriteLine(output.ToString()); } }