Load an XML and query using LINQ.
01
using
System;
02
System.Collections.Generic;
03
System.Linq;
04
System.Xml.Linq;
05
System.Text;
06
07
namespace
Demo
08
{
09
class
Program
10
11
static
void
Main(
string
[] args)
12
13
xmlFileName =
@"C:\CustomerOrders.xml"
;
14
XDocument cust = XDocument.Load(xmlFileName);
15
16
Console.WriteLine(
"Elements in XML:"
);
17
var qResult = from c
in
cust.Elements()
18
select c.Name;
19
foreach
(var itemList
qResult)
20
21
Console.WriteLine(itemList);
22
}
23
Console.Write(
"Press Enter to continue:"
24
Console.ReadLine();
25
26
27
28