Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (47 loc) · 1.61 KB
/
Copy pathProgram.cs
File metadata and controls
60 lines (47 loc) · 1.61 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace XmlExample
{
class Program
{
static void Main(string[] args)
{
XElement xelement = XElement.Load(@"..\..\students.xml");
// ReadXML(xelement);
//ReadSingleElements(xelement);
GetFemales(xelement);
Console.ReadLine();
}
private static void GetFemales(XElement xelement)
{
var result = from nm in xelement.Elements("record")
where (string)nm.Element("Gender") == "Female"
select nm;
List<Student> myStudents = new List<Student>();
//List<Student> list_course = result.ToList<Student>();
}
private static void ReadSingleElements(XElement xelement)
{
IEnumerable<XElement> employees = xelement.Elements();
Console.WriteLine("List of all Employee Names :");
foreach (var employee in employees)
{
Console.WriteLine(employee.Element("FName").Value + " " + employee.Element("LName").Value);
}
}
private static void ReadXML(XElement xelement)
{
//XElement xelement = XElement.Load(@"..\..\data\students.xml");
IEnumerable<XElement> myStudents = xelement.Elements();
// Read the entire XML
foreach (var student in myStudents)
{
Console.WriteLine(student);
}
}
}
}