c# xml文件下移除指定的节点和节点下所有的内容
xml如下:<?xmlversion="1.0"encoding="utf-8"?><students><studentId="1"Name="a"Sex="女"Tel=...
xml如下:
<?xml version="1.0" encoding="utf-8"?>
<students>
<student Id="1" Name="a" Sex="女" Tel="124141241241241" Check="true" />
<student Id="2" Name="0" Sex="女" Tel="152....." Check="false" />
<student Id="3" Name="b" Sex="男" Tel="124141241241241" Check="true" />
</students>
我想让xml变成:
<?xml version="1.0" encoding="utf-8"?>
<students>
<student Id="1" Name="a" Sex="女" Tel="124141241241241" Check="true" />
<student Id="3" Name="b" Sex="男" Tel="124141241241241" Check="true" />
</students> 展开
<?xml version="1.0" encoding="utf-8"?>
<students>
<student Id="1" Name="a" Sex="女" Tel="124141241241241" Check="true" />
<student Id="2" Name="0" Sex="女" Tel="152....." Check="false" />
<student Id="3" Name="b" Sex="男" Tel="124141241241241" Check="true" />
</students>
我想让xml变成:
<?xml version="1.0" encoding="utf-8"?>
<students>
<student Id="1" Name="a" Sex="女" Tel="124141241241241" Check="true" />
<student Id="3" Name="b" Sex="男" Tel="124141241241241" Check="true" />
</students> 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/App_Data/XMLFile1.xml"));//XML路迹租闭径
XmlElement root = doc.DocumentElement;
root.RemoveChild(root.ChildNodes[1]);
doc.Save(Server.MapPath("~/App_Data/XMLFile1.xml"姿裂));//XML路径型简
doc.Load(Server.MapPath("~/App_Data/XMLFile1.xml"));//XML路迹租闭径
XmlElement root = doc.DocumentElement;
root.RemoveChild(root.ChildNodes[1]);
doc.Save(Server.MapPath("~/App_Data/XMLFile1.xml"姿裂));//XML路径型简
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询