2 u013015636 u013015636 于 2013.12.22 21:15 提问

asp.net实现对xmldtd文件的增删改

为什么我在后台代码中引用的时候说我实体没法用?还有就是怎么把xml的dtd的内容和第一行也显示出来呢???求助!!!非常感谢!!!1
xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE classlist [
<!ELEMENT classlist (class*)>
<!ELEMENT class (classNumber,classShow,teacher,future,school)>
<!ELEMENT classNumber (#PCDATA)>
<!ELEMENT classShow (#PCDATA)>
<!ELEMENT teacher (name,phone,office)>
<!ELEMENT future (#PCDATA)>
<!ELEMENT school (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT office (#PCDATA)>
<!ENTITY 所属学校 "郑州大学软件学校北校区">
<!ATTLIST teacher sex (man|woman) #REQUIRED>
<!ATTLIST classNumber 单位 CDATA #REQUIRED>
]>



JAVA班,代码比较难吧、反正感觉挺难的


12345
水环楼

还行吧
&所属学校;


后台代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("XMLFile.xml"));
ViewState["ds"] = ds;
BindGVList();
}
}

     void BindGVList()
{
    DataSet ds = (DataSet)ViewState["ds"];
    DataTable dt = ds.Tables[0];
    gvClass.DataSource = dt;
    gvClass.DataBind();

     lstClass.DataSource = dt;
     lstClass.DataTextField = "classNumber";
     lstClass.DataBind();
}
     protected void btnAdd_Click(object sender, EventArgs e)
     {
         DataSet ds = (DataSet)ViewState["ds"];
         DataTable dt = ds.Tables[0];
         DataRow row = dt.NewRow();
         row[0] = txtBanji.Text;
         row[1] = txtShow.Text;
         row[2] = txtTeacher.Text.Trim();
         row[3] = txtFuture.Text;
         dt.Rows.Add(row);

         ds.WriteXml(Server.MapPath("XMLFile.xml"));
         BindGVList();
     }
     protected void btnUpdate_Click(object sender, EventArgs e)
     {
         DataSet ds = (DataSet)ViewState["ds"];
         DataTable dt = ds.Tables[0];
         int i = lstClass.SelectedIndex;
         dt.Rows[i][0] = txtBanji.Text;
         dt.Rows[i][1] = txtShow.Text;
         dt.Rows[i][2] = txtTeacher.Text;
         dt.Rows[i][3] = txtFuture.Text;
         ds.WriteXml(Server.MapPath("XMLFile.xml"));
         BindGVList();
     }
     protected void btnDelete_Click(object sender, EventArgs e)
     {
         DataSet ds = (DataSet)ViewState["ds"];
         DataTable dt = ds.Tables[0];
         dt.Rows.RemoveAt(lstClass.SelectedIndex);
         ds.WriteXml(Server.MapPath("XMLFile.xml"));
         BindGVList();

     }
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!