如何使用C#将新组件插入现有XML [英] How to insert new component to existing XML using C#
本文介绍了如何使用C#将新组件插入现有XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C#将新标记(例如新标记)插入现有XML中
如何执行此操作
How to insert new components such as new tags to existing XML using C#
How to do this
推荐答案
尝试
如何在C#.Net中编辑Xml文件 [ ^ ]
初学者教程 [ ^ ]
视频教程 [< a href =http://thenewboston.org/watch.php?cat=15&number=111target =_ blanktitle =新窗口> ^ ]
Try
How to Edit Xml file in C#.Net [^]
Beginners Tutorial[^]
Video Tutorial[^]
.NET FCL以不同的方式提供XML读取和生成。您可以选择最适合您的情况。这是我对他们的简短概述:
XML reading and generation is offered by .NET FCL in different ways. You can select the one most convenient for your case. This is my short overview of them:
- 使用
System.Xml.XmlDocument
class 。它实现了DOM接口;如果文档的大小不是太大,这种方式是最简单和最好的。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [ ^ ]。 - 使用类
System.Xml.XmlTextWriter
和System.Xml.XmlTextReader
;这是最快的阅读方式,特别是你需要跳过一些数据。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx [ ^ ], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ ^ ]。 - 使用类
系统.Xml.Linq.XDocument
;这是类似于XmlDocument
的最合适的方式,支持LINQ to XML Programming。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [ ^ ],http://msdn.microsoft.com/en-us/library/bb387063.aspx [ ^ ]。
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
andSystem.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that ofXmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
这篇关于如何使用C#将新组件插入现有XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文