将xml文件解析为c#文本文件 [英] parse xml file to c# text file
本文介绍了将xml文件解析为c#文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好。我是c#的新手。我试图将xml文件的元素解析为c#中的文本框。
任何人都可以帮我解决这个问题吗?
Hello. I am new to c#. I am trying to parse elements of a xml file to the text boxes in c#.
can any one help me on how to go for this?
推荐答案
如何使用C#中的XmlReader读取/解析XML / a> [ ^ ]
在C#中使用XmlReader类 [ ^ ]
您可以使用.NET FCL提供的至少三种不同的解析方式。以下是我对它们的简短概述:
You can use at least three different ways of parsing offered by .NET FCL. Here is my short overview of them:
- 使用
System.Xml.XmlDocument
class 。它实现了DOM接口;如果文档的大小不是太大,这种方式是最简单和最好的。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [ ^ ]。 - 使用类
System.Xml.XmlTextReader
;这是最快的阅读方式,特别是你需要跳过一些数据。
参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ ^ ]。 - 使用类
System.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 class
System.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.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文件解析为c#文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文