XML删除未含有条件的子节点
<power_line>
<name>嘉华305线 </name>
<sap_id>5020-S-0000-0065 </sap_id>
<dydj>35kV </dydj>
<poles>
<pole>
<name>嘉华305线电缆电缆#0 </name>
<xh>0 </xh>
<sap_id>000000000040719166 </sap_id>
</pole>
<pole>
<name>嘉华305线电缆支架 </name>
<xh>0 </xh>
<sap_id>000000000040627384 </sap_id>
<jd>120.7071280158 </jd>
<wd>30.6240158394 </wd>
</pole>
<pole>
<name>嘉华305线电缆电缆#1 </name>
<xh>1 </xh>
<sap_id>000000000040716119 </sap_id>
</pole>
</poles>
</power_line>
我想把不含有 <jd>的子节点都删除掉.请问要怎么做?
遍历 pole + 判断 删除...
或者:
C# code:
using System;
using System.Diagnostics;
using System.Xml;
namespace ConsoleApplication9 {
class Program {
static void Main() {
string xml = @"
<power_line>
<name>嘉华305线 </name>
<sap_id>50
相关问答:
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
思路:要用c#生成一个播放机的播放列表的xml,例如:
<daty datys='2010-04-05' datye='2010-05-01' > //这是播放的日期段
<time times='01:12:00' timee='02:30:00'> ......
我用XmlDocument生成XML
XmlElement remarkNode = node.OwnerDocument.CreateElement("remark");
remark1Node.InnerXml = "";
如果InnerXml赋值不为空,则生成的标记是没问题的,比如:<r ......
用SAX解析XML中,使用这段代码
String feed="http://www.google.com/ig/api?weather="+strCity;
URL url = new URL(feed.replace(" ", "%20"));
......