OKIEWARDOYO

VISUAL C# No.44 5

Jul 15th, 2014
3,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml.Linq;
  7.  
  8. namespace ContohXElement
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             XElement xmlTree1 = new XElement("Root",
  15.                 new XElement("Child1", 1),
  16.                 new XElement("Child2", 2),
  17.                 new XElement("Child3", 3),
  18.                 new XElement("Child4", 4),
  19.                 new XElement("Child5", 5),
  20.                 new XElement("Child6", 6)
  21.             );
  22.  
  23.             XElement xmlTree2 = new XElement("Root",
  24.                 from el in xmlTree1.Elements()
  25.                 where ((int)el >= 3 && (int)el <= 5)
  26.                 select el
  27.             );
  28.             Console.WriteLine(xmlTree2);
  29.             Console.ReadKey();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment