Advertisement
OKIEWARDOYO

VISUAL C# No.44 4

Jul 15th, 2014
3,538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 LinqToXml
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             //Data source
  15.             XElement xmlFile = XElement.Load(@"E:\MAS OKIE DOCS\MEDIATUTORIAL\41.1 Mengenal LINQ (Language Integrated Query)\LinqToXml\LinqToXml\DataSource.xml");  
  16.  
  17.             //Create Query
  18.             IEnumerable<XElement> dataSiswa = from abc in xmlFile.Elements("student").Elements("name")
  19.                                               select abc;
  20.  
  21.             //Execute Query
  22.             foreach (string data in dataSiswa)
  23.             {
  24.                 Console.WriteLine(data);
  25.             }
  26.             Console.ReadKey();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement