目前,我有以下的code:
声明XPathNodeIterator theNodes = theNav.Select(theXPath.ToString());
而(theNodes.MoveNext())
{
//一些尝试,我虽然很接近
//theNodes.RemoveChild(theNodes.Current.OuterXml);
//theNodes.Current.DeleteSelf();
}
我已经设置的XPath什么,我想在XML返回,我想删除一个循环的一切。我曾尝试删除信息的一些方法,但它简化版,像我的语法。我发现微软支持的一个例子: http://support.microsoft.com/kb/317666 但我想用这一点的同时,而不是为每个。
有任何意见或问题是AP preciated。
解决方案 字符串nodeXPath =你的X路;
XmlDocument的文档=新的XmlDocument();
document.Load(/ *文件路径* /);
XmlNode的节点= document.SelectSingleNode(nodeXPath);
node.RemoveAll();
XmlNode的parentnode = node.ParentNode;
parentnode.RemoveChild(节点);
document.Save(文件路径);
I currently have the following code:
XPathNodeIterator theNodes = theNav.Select(theXPath.ToString());
while (theNodes.MoveNext())
{
//some attempts i though were close
//theNodes.RemoveChild(theNodes.Current.OuterXml);
//theNodes.Current.DeleteSelf();
}
I have set xpath to what I want to return in xml and I want to delete everything that is looped. I have tried a few ways of deleting the information but it does't like my syntax. I found an example on Microsoft support: http://support.microsoft.com/kb/317666 but I would like to use this while instead of a for each.
Any comments or questions are appreciated.
解决方案string nodeXPath = "your x path";
XmlDocument document = new XmlDocument();
document.Load(/*your file path*/);
XmlNode node = document.SelectSingleNode(nodeXPath);
node.RemoveAll();
XmlNode parentnode = node.ParentNode;
parentnode.RemoveChild(node);
document.Save("File Path");
上一篇:物业未启用设置触发与实施UITypeEditor的物业、UITypeEditor
下一篇:我如何获得OnClickListener正与一个RelativeLayout的自定义视图?自定义、视图、如何获得、RelativeLayout