Xml File
LINQ QUERY to fetch particular Student Information:
private List<string> GetStudentDetails(string _usn)
{
List<string> _lstStudentInfo=new List<string>();
XmlDocument xdcDocument = new XmlDocument();
XElement root =XDocument.Load(@"H:\CollegeSeminar\StudentInfo.xml").Root;
var result = root.Elements("Student").
Where(x => x.Attribute("USN").Value == _studentId).
Select(i => new { Name = i.Attribute("Name").Value,
StudentAddress = i.Attribute("Address").Value,StudentUSN= i.Attribute("USN").Value }).ToList();
Select(i => new { Name = i.Attribute("Name").Value,
StudentAddress = i.Attribute("Address").Value,StudentUSN= i.Attribute("USN").Value }).ToList();
//To get the values
_lstStudentInfo.Add(result[0].Name);}
_lstStudentInfo.Add(result[0].StudentAddress);
_lstStudentInfo.Add(result[0].StudentUSN);
return _lstStudentInfo;