如何使用C#编辑,更新或删除xml文件中的特定节点 [英] How to edit, update or delete particular node in a xml file using c#

查看:304
本文介绍了如何使用C#编辑,更新或删除xml文件中的特定节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个xml文件

Here is a xml file

<CarsService>
  <make name="AAA">
    <model name="ssss">
      <color name="Red" />
    </model>
    <model name="qqqq">
      <color name="Green" />
    </model>
  </make>
  <make name="AAB">
    <model name="aaaa">
      <color name="Black" />
    </model>
  </make>
  <make name="AAC">
    <model name="dddd">
      <color name="Blue" />
    </model>
  </make>
</CarsService>


如果我想在现有节点内插入一个新节点,该怎么写?
假设我要在make节点"AAA"和模型节点"qqqq"中插入一个属性属性为Pink的颜色节点.
该怎么做?

如果我想修改任何子节点;我该怎么办?甚至删除某些特定节点或子节点也要怎么做?

在此先谢谢您.


If i want to insert a new node inside the existing node how to write that?
Suppose i want to insert a color node which has a attribute say Pink in make node "AAA" and model node "qqqq".
How to do that?

If i want to modify any of sub node; how should i do that? even to delete some specific node or sub node how to do that also?

Thanks in advance.

推荐答案

以下链接具有必填信息

http://stackoverflow.com/questions/874640/edit-xml-node [ ^ ]

http://stackoverflow.com/questions/919645/how-to-delete-node-from-xml-file-using-c-sharp [
Following links have the required information

http://stackoverflow.com/questions/874640/edit-xml-node[^]

http://stackoverflow.com/questions/919645/how-to-delete-node-from-xml-file-using-c-sharp[^]


请参阅以下链接
文章:
http://kavstech.blogspot.com/2009/07/append- new-node-in-xml-file.html [ ^ ]
http://kavstech.blogspot.com/2009/06/how- to-remove-nodes-from-xml.html [ ^ ]


相似线程:
http://forums.asp.net/t/1461544.aspx [ http://stackoverflow.com/questions/482986/how-to-update-a- xml-node [^ ]


祝一切顺利.
--Amit
Refer the links below for
Articles:
http://kavstech.blogspot.com/2009/07/append-new-node-in-xml-file.html[^]
http://kavstech.blogspot.com/2009/06/how-to-remove-nodes-from-xml.html[^]

and
Similar Threads:
http://forums.asp.net/t/1461544.aspx[^]
http://stackoverflow.com/questions/482986/how-to-update-a-xml-node[^]


All the best.
--Amit


这篇关于如何使用C#编辑,更新或删除xml文件中的特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆