xml文件的常用读写

            XmlDocument xmldoc = new XmlDocument();
            StreamReader sr = new StreamReader(System.Configuration.ConfigurationManager.AppSettings["OperationDefinitionsFile"]);
            xmldoc.LoadXml(sr.ReadToEnd());
            XmlNode root = xmldoc.SelectSingleNode("OpenBoxMethods");
            XmlNodeList xn = xmldoc.SelectNodes("//OpenBoxMethods/method");
            foreach (XmlNode no in xn)
            {
                if (ops.Contains(no.Attributes["name"].Value.Trim()))
                    root.RemoveChild(no);
            }
           // xmldoc.SelectSingleNode(
            sr.Close();
            sr = null;


            StreamWriter sw = new StreamWriter(
            System.Configuration.ConfigurationManager.AppSettings["OperationDefinitionsFile"], false);
            sw.WriteLine(xmldoc.OuterXml);
            sw.Close();

你可能感兴趣的:(xml)