[英]How to read xml file from windows form application in c#
How to read xml file from windows form application in c#? 如何从c#中的windows表单应用程序中读取xml文件? I am new in this .net framework prograaming.
我是这个.net框架编程的新手。 I have 3.5 .net framework please give simple program for it
我有3.5 .net框架请给它简单的程序
The simplest way to read an XML file into memory is to use the XDocument.Load method. 将XML文件读入内存的最简单方法是使用XDocument.Load方法。 This method takes a file path and returns an XDocument instance which can be used to query the contents
此方法采用文件路径并返回可用于查询内容的XDocument实例
XDocument doc = XDocument.Load(@"c:\path\to\the\xmlfile.xml");
If you're working with an older API, you may need to use the XmlDocument class. 如果您使用的是较旧的API,则可能需要使用XmlDocument类。 It can be loaded in the following way
它可以通过以下方式加载
XmlDocument doc = new XmlDocument();
doc.Load(@"c:\path\to\the\xmlfile.xml");
If you're using .Net 3.5 or later, you can use the XDocument class to read and write XML. 如果您使用的是.Net 3.5或更高版本,则可以使用XDocument类来读取和写入XML。
If you're still in .Net 2.0, you can use the XmlDocument class. 如果您仍在.Net 2.0中,则可以使用XmlDocument类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.