求助删除xml节点的问题
<?xml version= "1.0 " encoding= "UTF-8 "?>
<rss version= "2.0 ">
<channel>
<item>
<title> 台独分子为何怕奥运圣火 - 人民网 </title>
<link> http://news.google.com/news/url?sa=T&ct=cn/0-0&fd=R&url=http://blog.people.com.cn/blog/log/showlog.jspe%3Flog_id%3D1177727952150946%26site_id%3D5217%26static%3D1&cid=1112905632&ei=cSAzRo2mMY-OqQP6p6CCBg </link>
<guid isPermaLink= "false "> tag:news.google.com,2005:cluster=425597a0 </guid>
<pubDate> Sat, 28 Apr 2007 08:12:32 GMT </pubDate>
</item>
<item>
<title> 拒接奥运圣火高雄2009年世运会添变数 - 新浪网 </title>
<link> http://news.google.com/news/url?sa=T&ct=cn/9-0&fd=R&url=http://news.sina.com.cn/c/2007-04-28/152511735048s.shtml&cid=1112929595&ei=cSAzRo2mMY-OqQP6p6CCBg </link>
<guid isPermaLink= "false "> tag:news.google.com,2005:cluster=4255f53b </guid>
<pubDate> Sat, 28 Apr 2007 07:32:48 GMT </pubDate>
</item>
</channel>
</rss>
上面是xml文件,我想删除xml文件中所有 <link> 节点的http://news.google.com/news/url?sa=T&ct=cn/0-0&fd=R&url=
请问具体怎么实现?谢谢!
------解决方案--------------------string str= " ";
XmlReader reader = XmlReader.Create( "yours.xml ");
while(reader.Read())
{
if(reader.NodeType==XmlNodeType.Element)
{
if(reader.Name== "link ")
{
str=reader.ReadString();
str.subString() //这里可以把前面那段处理掉 做字符串处理
具体代码我没有环境 一时写不出来
}
}
}
------解决方案--------------------http://topic.csdn.net/t/20040629/10/3130404.html
写错解答了 还是现成的有 LZ看一下吧哈
------解决方案--------------------string xmlPath = "yours.xml ";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNodeList nodeList=xmlDoc.SelectSingleNode( "yours ").ChildNodes;//获取bookstore节点的所有子节点
foreach(XmlNode xn in nodeList)//遍历所有子节点
{
XmlElement xe2=(XmlElement)xn;//转换类型
if (xe2.Name == "link ")//如果找到
{
xe2.InnerText = xe2.InnerText.Substring(i);
}
}
xmlDoc.Save( "yours.xml ");//保存。
------解决方案--------------------string str = "http://news.google.com/news/url?sa=T&ct=cn/0-0&fd=R&url= ";
int i = s.Length;
string xmlPath = "yours.xml ";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNodeList nodeList=xmlDoc.SelectSingleNode( "yours ").Child