且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用csharp的XML操作

更新时间:2023-11-24 16:34:16

如果文件相对较小,则最简单的方法是使用DOM.使用System.Xml.XmlDataDocument.

注意:永远不要直接使用XML节点.对于DOM,请阅读完整的XML文档,操作DOM节点(它们与XML元素和属性具有一一对应的关系,但它们并不相同).您将使用的主要类是System.Xml.XmlNode以及派生类.看一看这些课程的帮助;您将立即看到如何操作它们.

—SA
If the files are relatively small, the simplest way is using DOM. Use System.Xml.XmlDataDocument.

Note: you should not ever work with XML nodes directly. In case of DOM, you read full XML document, manipulate DOM nodes (they have one-to-one correspondence with XML Elements and Attributes, but they are not the same). The main class you will work is System.Xml.XmlNode, as well as derived classes. Take a look at the help of those classes; and you will immediately see how to manipulate them.

—SA


成员7794889308写道:
Member 7794889308 wrote:

如果我要删除xml节点,使用c#在以下xml示例中更新现有节点并添加新节点,该怎么办?

If i want to delete an xml node,update an existing node and add a new node in the following xml sample using c#, what should i do?



我建议你看看这个.

使用C#操纵XML文件数据 [ ^ ]



I suggest you take a look at this.

Manipulate XML File Data Using C#[^]