Mega Code Archive

 
Categories / C# / XML LINQ
 

XElement Class Represents an XML element

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