如何创建类似于下面的格式的xml文件 [英] how to create xml file like below formate
本文介绍了如何创建类似于下面的格式的xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是xml的新手,如何创建xml文件,如下面的格式
请给我c#中的编码。
Am new to xml, how to create xml file like below formate
please give me the codings in c#.
<Countries>
<Country name ="ANDORRA">
<state>Andorra (general)</state>
<state>Andorra</state>
</Country>
<Country name ="United Arab Emirates">
<state>Abu Z¸aby</state>
<state>Umm al Qaywayn</state>
</Country>
提前感谢...!
thanks in advance...!
推荐答案
有不同的方式要解析和编写由.NET FCL以编程方式提供的XML文档,请参阅我的快速概述:
There are different ways to parse and compose XML document programmatically provided by .NET FCL, please see my quick overview:
- 使用
系统。 Xml.XmlDocument
类。它实现了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[^].
祝你好运,
这篇关于如何创建类似于下面的格式的xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文