1.使用XML读取
<% @ Page Language="C#"%>
<html>
<body>
<h3><font face="Verdana">读取XML方法一</font></h3>
<from runat=server>
<asp:Xml id="xml1" DocumentSource="grade.xml" runat="server" />
</from>
</body>
</html>
2.使用DOM技术
<% @ Page Language="C#"%>
<% @ Import Namespace="System.Xml"%>
<% @ Import Namespace="System.Xml.Xsl"%>
<html>
<script language="C#" runat="server">
void Page_Load(Object sender,EventArgs e)
{
XmlDocument doc=new XmlDocument();
doc.Load(Server.MapPath("grade.xml"));
xml1.Document=doc;
}
</script>
<body>
<h3><font face="Verdana">读取XML方法二</font></h3>
<from runat=server>
<asp:Xml id="xml1" runat="server" />
</from>
</body>
</html>
3.使用DataSet读取
<% @ Page Language="C#"%>
<% @ Import Namespace="System.Data"%>
<% @ Import Namespace="System.Data.OleDb"%>
<script language="C#" runat="server">
void Page_Load(Object sender,EventArgs e)
{
DataSet objDataSet=new DataSet();
objDataSet.ReadXml(Server.MapPath("grade.xml"));
dgEmployees.DataSource=objDataSet.Tables["student"].DefaultView;
dgEmployees.DataBind();
}
</script>
<body>
<h3><font face="Verdana">读取XML方法三</font></h3>
<asp:DataGrid id="dgEmployees" runat="server" />
</body>
</html>