<Newslist>
  <news Type="Exclusive">
    <iNewsOfficeId>16</iNewsOfficeId>
    <INewsPaperId>1</INewsPaperId>
    <Data>2009-01-01</Data>
    <title>白河社区吹拂和谐“春风”</title>
    <sRefernceUrl>http://192.168.66.202:888/慈溪日报/20090407/page-001.xml@8</sRefernceUrl>
  </news>
  <news Type="Exclusive">
    <iNewsOfficeId>16</iNewsOfficeId>
    <INewsPaperId>1</INewsPaperId>
    <Data>2009-01-01</Data>
    <title>新能源产业振兴规划拆解 规划目标可能翻若干倍</title>
    <sRefernceUrl>http://192.168.66.202:888/慈溪日报/20090407/page-001.xml@8</sRefernceUrl>
  </news>
</Newslist>
我要根据title进行删除   比如根据  白河社区吹拂和谐“春风”  我要删除这个news里面的所有节点 高手赐教啊 

解决方案 »

  1.   

      protected void Button3_Click(object sender, EventArgs e)
        {
            DelXml("白河社区吹拂和谐“春风”");
        }
        void DelXml(string title)
        {
            XmlDocument xmlDoc = new XmlDocument();
            string strPath = Server.MapPath("../xml/xmlfile.xml");
            xmlDoc.Load(strPath);
            XmlNode root = xmlDoc.SelectSingleNode("Newslist");
            XmlNodeList xnl = xmlDoc.SelectSingleNode("Newslist").ChildNodes;
            for (int i = 0; i < xnl.Count; i++)
            {
                XmlElement xe = (XmlElement)xnl.Item(i);
                XmlNode xmlNode = xmlDoc.SelectSingleNode("Newslist/news/title");
                if (xmlNode.InnerText  == title)
                {
                    root.RemoveChild(xe);
                    if (i < xnl.Count) i = i - 1;
                }
            }
            xmlDoc.Save(strPath);
        }
      

  2.   

    楼上理解错了,人家是要在SQL Server 2005 中操作 XML 字段,要用SQL语句
      

  3.   


     DelXMLByContext("白河社区吹拂和谐“春风” ");        static void DelXMLByContext(string ctx)
            {
              XmlDocument doc = new XmlDocument();
              string file = "~/xmlfile.xml";
              doc.Load(file);          XmlNode node = doc.SelectSingleNode(string.Format("//news[title='{0}']", ctx));          node.ParentNode.RemoveChild(node);
              
              doc.Save(file);
            }
      

  4.   

    楼上两位都理解错了  是要用sql来解决  不是code   不过还是谢谢了  如果没高手帮忙解决  一定送分