private string xmlPath=Application.StartupPath.Replace("bin\\Debug","") + "InstallFiles\\BookMarks.xml";
        private XmlDocument _XmlDoc;
        public XmlDocument XmlDoc 
        {
            get 
            {
                _XmlDoc = new XmlDocument();
                _XmlDoc.Load(xmlPath);
                return _XmlDoc;
            }
        }
       public bool DelBookName(string nodeName) 
        {
            XmlNodeList xmlNodes = XmlDoc.SelectSingleNode("BookMarks").ChildNodes;
            foreach (XmlNode node in xmlNodes)
            {
                XmlElement xmlEle = (XmlElement)node;
                if (xmlEle.GetAttribute("Name").Equals(nodeName))
                {
                    node.ParentNode.RemoveChild(node);
                    //xmlEle.ParentNode.RemoveChild(node);
                    XmlDoc.Save(xmlPath);
                    return true;
                }
             }
             return false;
        }xml

解决方案 »

  1.   

    代码没什么问题,你跟踪看运行到了没
      
    *****************************************************************************
    http://feiyun0112.cnblogs.com/
      

  2.   

    你每次得到的XmlDoc都是一个新的实例。
      

  3.   

    public XmlDocument XmlDoc 
            {
                get 
                {
                    if (_XmlDoc==null)
                    {
                        _XmlDoc = new XmlDocument();
                        _XmlDoc.Load(xmlPath);
                    }
                    return _XmlDoc;
                }
            }改成这样就行了,谢谢大家了