01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.IO;
04.
using
System.Linq;
05.
using
Windows.Devices.Geolocation;
06.
using
Windows.Foundation;
07.
using
Windows.Foundation.Collections;
08.
using
Windows.UI.Core;
09.
using
Windows.UI.Xaml;
10.
using
Windows.UI.Xaml.Controls;
11.
using
Windows.UI.Xaml.Controls.Primitives;
12.
using
Windows.UI.Xaml.Data;
13.
using
Windows.UI.Xaml.Input;
14.
using
Windows.UI.Xaml.Media;
15.
using
Windows.UI.Xaml.Navigation;
16.
17.
using
System.Xml.Linq;
18.
19.
20.
21.
namespace
WindowsStoreApps
22.
{
23.
/// <summary>
24.
/// An empty page that can be used on its own or navigated to within a Frame.
25.
/// </summary>
26.
///
27.
28.
public
sealed
partial
class
MainPage : Page
29.
{
30.
public
MainPage()
31.
{
32.
this
.InitializeComponent();
33.
}
34.
35.
public
class
myCustomer
36.
{
37.
public
string
CustomerID {
get
;
set
; }
38.
public
string
Name {
get
;
set
; }
39.
public
string
Email {
get
;
set
; }
40.
public
string
CountryCode {
get
;
set
; }
41.
public
string
Budget {
get
;
set
; }
42.
public
string
Used {
get
;
set
; }
43.
}
44.
45.
protected
override
void
OnNavigatedTo(NavigationEventArgs e)
46.
{
47.
List<myCustomer> myCustomer =
new
List<myCustomer>();
48.
XDocument loadData = XDocument.Load(
"XML/myXML.xml"
);
49.
50.
var data = from query
in
loadData.Descendants(
"customer"
)
51.
select
new
myCustomer()
52.
{
53.
CustomerID = (
string
)query.Element(
"CustomerID"
),
54.
Name = (
string
)query.Element(
"Name"
),
55.
Email = (
string
)query.Element(
"Email"
),
56.
CountryCode = (
string
)query.Element(
"CountryCode"
),
57.
Budget = (
string
)query.Element(
"Budget"
),
58.
Used = (
string
)query.Element(
"Used"
)
59.
};
60.
61.
this
.lblResult.Text =
string
.Empty;
62.
63.
foreach
(myCustomer customer
in
data)
64.
{
65.
66.
67.
68.
69.
70.
71.
this
.lblResult.Text =
this
.lblResult.Text +
"CustomerID : "
+ customer.CustomerID.ToString();
72.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
73.
this
.lblResult.Text =
this
.lblResult.Text +
"Name : "
+ customer.Name.ToString();
74.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
75.
this
.lblResult.Text =
this
.lblResult.Text +
"Email : "
+ customer.Email.ToString();
76.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
77.
this
.lblResult.Text =
this
.lblResult.Text +
"CountryCode : "
+ customer.CountryCode.ToString();
78.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
79.
this
.lblResult.Text =
this
.lblResult.Text +
"Budget : "
+ customer.Budget.ToString();
80.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
81.
this
.lblResult.Text =
this
.lblResult.Text +
"Used : "
+ customer.Used.ToString();
82.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
83.
this
.lblResult.Text =
this
.lblResult.Text +
"======================"
;
84.
this
.lblResult.Text =
this
.lblResult.Text + Environment.NewLine;
85.
}
86.
87.
}
88.
89.
}
90.
}