XML 檔案 people.xml:
<People>
<Person><Name>張三</Name><Phone>66666666</Phone><Address>北京市海澱區</Address></Person>
<Person><Name>李四</Name><Phone>88888888</Phone><Address>北京市豐台區</Address></Person>
<Person><Name>王五</Name><Phone>99999999</Phone><Address>北京市朝陽區</Address></Person>
</People>
程式碼:
void Page_Load(object sender, System.EventArgs e)
{
DataSet myDS = new DataSet();
myDS.ReadXml(Server.MapPath("people.xml"));
Label1.Text = "表的名稱是:" + myDS.Tables[0].TableName;
DataGrid1.DataSource = myDS.Tables[0];
DataGrid1.DataBind();
}
來源:https://mjgforever.cnblogs.com/