如何使用C#添加XML节点? [英] How to add XML node using C#?

查看:92
本文介绍了如何使用C#添加XML节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用GetXml()函数生成数据集到xml。



string xml = DS_Test.GetXml();



现在我用



xml = xml.replace(<& _lt_node>,);



以上代码使用替换节点为空。



此xml有超过2500行。现在我想首先添加一个节点,最后添加如何add.means添加节点以启动xml和xml.how的节点结束。



我尝试了什么:



i使用replace方法替换xml节点如何添加新的xml父节点。

i generate dataset to xml using GetXml() function.

string xml = DS_Test.GetXml();

Now i use

xml=xml.replace("<&_lt_node>" , "");

above code to use replace the node empty.

This xml have above 2500 lines. now i want to add one node in first and last how to add.means add the node to start of the xml and the node end of the xml.how to do this.

What I have tried:

i use replace method to replace the xml node how to add the new xml parent node.

推荐答案

实现这一目标的方法很少......例如,您可以使用以下类别之一:

There's few ways to achieve that... For example, you can use one of below classes:


  1. XmlDocument Class(System.Xml) ) [ ^ ]
  2. XDocument类(System.Xml.Linq) [ ^ ]

  1. XmlDocument Class (System.Xml)[^]
  2. XDocument Class (System.Xml.Linq)[^]





如果您想了解更多详情,您必须提供更多信息。



If you want to get further details, you have to provide more information.


这篇关于如何使用C#添加XML节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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