You are on page 1of 1

Aim:- 2) Display Employees Details Using

LinkView To XML
Code :- [i] Default.aspx.cs
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
System.Xml.Linq.XDocument doc =
System.Xml.Linq.XDocument.Load(HttpContext.Current.Server.MapPath("Student.xml"));
var cust = from e1 in doc.Descendants("Student") select new { Age = e1.Element("Studentage").Value, Name = e1.Element("Student-name").Value };
GridView1.DataSource = cust;
GridView1.DataBind();
}
}

[ii] Student.xml
<?xml version="1.0" encoding="utf-8" ?>
<Studnets>
<Student>
<Student-name>Goku</Student-name>
<Student-age>42</Student-age>
</Student>
</Studnets>

Output:-

You might also like