日期:2014-05-17  浏览次数:20481 次

关于repeater绑定xml特定的某行的数据
XML code

<?xml version="1.0" encoding="utf-8"?>
<ErrorInfo>
  <Error>
    <LOpertionID ID="20120827164554950">
      <StudentID ID="84">
        <LQuestionID ID="0">
          <LDateID ID="0">
            <LErrorReportingID ID="1">
              <FErrorNumber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="2">
              <FErrorNumber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="3">
              <FErrorNumber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="4">
              <FErrorNumber ID="0" />
            </LErrorReportingID>
          </LDateID>
        </LQuestionID>
        <LQuestionID ID="1">
          <LDateID ID="30017">
            <LErrorReportingID ID="1">
              <FErrorNUmber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="2">
              <FErrorNUmber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="3">
              <FErrorNUmber ID="0" />
            </LErrorReportingID>
            <LErrorReportingID ID="4">
              <FErrorNUmber ID="0" />
            </LErrorReportingID>
          </LDateID>
        </LQuestionID>
      </StudentID>
    </LOpertionID>
  </Error>
</ErrorInfo>


请问一下,我要怎么绑定lquestionID为1,LdateID为30017,LErrorReportingID为1的FErrorNumber
这个是我现在的代码
C# code

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep1 = e.Item.FindControl("repnumber1") as Repeater;//找到里层的repeater对象
                Repeater rep2 = e.Item.FindControl("repnumber2") as Repeater;
                Repeater rep3 = e.Item.FindControl("repnumber3") as Repeater;
                Repeater rep4 = e.Item.FindControl("repnumber4") as Repeater;
                //DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                //int typeid = Convert.ToInt32(rowv["FID"]); //获取填充子类的id
                XmlDocument xml = new XmlDocument();
                string url = Server.MapPath("Xml\\20120827164554950.xml");
                xml.Load(url);
                XmlNode root = xml.SelectSingleNode("ErrorInfo/Error");
                XmlNodeList nodelist = xml.SelectSingleNode("ErrorInfo/Error/LOpertionID/StudentID").ChildNodes;
                foreach (XmlNode xn1 in nodelist)
                {
                    XmlElement xe1 = (XmlElement)xn1;
                    if (xe1.GetAttribute("ID") == lid.ToString())
                    {
                        XmlNodeList lis = xe1.ChildNodes;
                        foreach (XmlNode xn2 in lis)
                        {
                            XmlElement xe2 = (XmlElement)xn2;
                            if (xe2.GetAttribute("ID") == "30016")
                            {
                                XmlNodeList list = xe2.ChildNodes;
                                foreach (XmlNode xn in list)
                                {