-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cs
More file actions
28 lines (25 loc) · 853 Bytes
/
Helper.cs
File metadata and controls
28 lines (25 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace StatesHelper
{
public class States
{
public string Name { get; set; }
public string Abbreviation { get; set; }
public string Country { get; set; }
public static IEnumerable<States> GetStatesFromXML()
{
var xElement = XDocument.Load(AppDomain.CurrentDomain.GetData("DataDirectory") + "States.xml").Element("states");
if (xElement == null) return null;
var ret = xElement.Elements("state").Select(t => new States
{
Name = t.Attribute("name").Value,
Abbreviation = t.Attribute("abbreviation").Value,
Country = t.Attribute("country").Value
}).ToList();
return ret;
}
}
}