public static void distinct(string filePath)
{
//1、创建XML文档对象
XmlDocument doc = new XmlDocument(); //2、加载指定路径的XML
doc.Load(filePath); //3、获得根节点
XmlElement root = doc.DocumentElement; //4-1、获得根节点的所有子节点
XmlNodeList allNodes = root.ChildNodes;
for (int i = ; i < allNodes.Count - ; i++)
{
XmlElement node_Element = (XmlElement)allNodes[i];
string currentNodeValue = node_Element.GetAttribute("Include");
for (int j = i + ; j < allNodes.Count; j++)
{
XmlElement node_Element_temp = (XmlElement)allNodes[j];
if (node_Element_temp.GetAttribute("Include") == currentNodeValue)
{
node_Element_temp.ParentNode.RemoveChild(node_Element_temp);
j--;
continue;
}
}
}
doc.Save(filePath);
}

调用

string path = @"..\..\upload\demo.xml";

distinct(path);

<?xml version="1.0" encoding="utf-8"?>
<ItemGroup>
<Compile Include="1" />
<Compile Include="1" />
<Compile Include="1" />
<Compile Include="2" />
<Compile Include="3" />
<Compile Include="1" />
<Compile Include="1" />
</ItemGroup>

最新文章

  1. C# 操作excel单元格居中
  2. myeclipse 2014 除了 默认加载的derby
  3. 点击每个li节点,都弹出其文本值及修改
  4. IOS 其它语言比较-Objc与JAVA的比较
  5. POJ 2002 统计正方形 HASH
  6. ECharts使用心得总结(二)
  7. BZOJ 3165 Segment
  8. java服务器知识
  9. linux怎样修改用户权限
  10. JSP中的EL语言
  11. 客户调查(client)
  12. Raid类型
  13. c# 对加密的MP4文件进行解密
  14. 【liferay】3、liferay 添加spring支持
  15. Windows运行GitStats
  16. SQL Server使用sp_spaceused查看表记录存在不准确的情况
  17. String Reconstruction (并查集)
  18. Controller层aop
  19. IP段,ASN与BGP之间的关系
  20. SharePoint下在Feature中动态Register/Remove HttpModule

热门文章

  1. Netty高性能之Reactor线程模型
  2. 【论文笔记】Training Very Deep Networks - Highway Networks
  3. 确保安全的HTTPS(对HTTP加密的几种技术,前端面试常问)第一篇
  4. mysql memory engine
  5. 修改zerolog使log输出的文件名可以在goland里自动定位--技巧
  6. [转]SpringMVC&lt;from:form&gt;表单标签和&lt;input&gt;表单标签简介
  7. [转]Ext.grid常用属性和方法
  8. thinkphp前台模版字符串截取
  9. 【.Net】Thread.Start()与ThreadPool.QueueUserWorkItem()的区别
  10. Linux下的微秒级别的定时器