添加 XML内Rows数据

      
        public static void addItemToXml(string method,string firstKey,string id,string checkName,string refValue)
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(txtValueHelper.txtValue);
            XmlNode xNode = xDoc.SelectSingleNode("Check");
            XmlElement xRoot = xDoc.CreateElement("CheckTable");
            xRoot.SetAttribute("ID", id);
            XmlElement xMethodName = xDoc.CreateElement("MethodName");
            xMethodName.InnerText = method;
            xRoot.AppendChild(xMethodName);
            XmlElement xFirKey = xDoc.CreateElement("MethodArgs");
           xFirKey.InnerText = firstKey;
           xRoot.AppendChild(xFirKey);
           // XmlElement xCheckid = xDoc.CreateElement("Checkid");
           // xCheckid.InnerText = id;
           // xRoot.AppendChild(xCheckid);
            XmlElement xCheckName = xDoc.CreateElement("CheckName");
            xCheckName.InnerText = checkName;
            xRoot.AppendChild(xCheckName);
           // xRoot.AppendChild(xCheckid);
            XmlElement xRefValue = xDoc.CreateElement("RefValue");
            xRefValue.InnerText = refValue;
            xRoot.AppendChild(xRefValue);
            XmlElement xCheckValue = xDoc.CreateElement("CheckValue");
            xCheckValue.InnerText = "1";
            xRoot.AppendChild(xCheckValue);
            xNode.AppendChild(xRoot);
            xDoc.Save(txtValueHelper.txtValue);
            MessageBox.Show("Add Sucess.");
        }

  

posted @ 2013-07-11 10:18  Ethan.Sun  阅读(315)  评论(0)    收藏  举报