#region DeleteXmlRows /// 〈summary〉 /// 删除strColumn列中值为ColumnValue的行 /// 〈/summary〉 /// 〈param name="strXmlPath"〉xml相对路径〈/param〉 /// 〈param name="strColumn"〉列名〈/param〉 /// 〈param name="ColumnValue"〉strColumn列中值为ColumnValue的行均会被删除〈/param〉 /// 〈returns〉〈/returns〉 public static bool DeleteXmlRows(string strXmlPath,string strColumn,string[] ColumnValue) { try { DataSet ds = new DataSet(); ds.ReadXml(GetXmlFullPath(strXmlPath)); //先判断行数 if(ds.Tables[0].Rows.Count 〉 0) { //判断行多还是删除的值多,多的for循环放在里面 if(ColumnValue.Length 〉 ds.Tables[0].Rows.Count) { for(int i=0; i 〈 ds.Tables[0].Rows.Count; i++) { for(int j=0; j 〈 ColumnValue.Length; j++) { //找到符合条件的行 if(ds.Tables[0].Rows[i][strColumn].ToString().Trim().Equals(ColumnValue[j])) { //删除行 ds.Tables[0].Rows[i].Delete(); } } } } else { for(int j=0; j 〈 ColumnValue.Length; j++) { for(int i=0; i 〈 ds.Tables[0].Rows.Count; i++) { //找到符合条件的行 if(ds.Tables[0].Rows[i][strColumn].ToString().Trim().Equals(ColumnValue[j])) { //删除行 ds.Tables[0].Rows[i].Delete(); } } } } ds.WriteXml(GetXmlFullPath(strXmlPath)); } return true; } catch(Exception) { return false; } } #endregion