In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "brief introduction of C# reading XML file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "C# read XML file brief introduction" bar!
C # reads the XML file:
After compiling NO2.cs, execution produces a "data.xml" file, where the data structure of the "data.xml" file is as follows:
Ma Jin Hu 239000 Feng Huang Street Chu Zhou City ANHUI Wang Tian 239000 Lang Ya Street He Fei City ANHUI Zou Wen Biao 100000 Sai Di Street Bei Jin City Bei Jin
In the following content, we use C # to read the XML file and use the ListView component to display it according to the data structure. The following figure shows the running interface after reading this XML.
To read XML data correctly, you must first understand the structure of XML.
1. Load the XML file to form a data stream.
You can load the XML file by creating a "XmlDocument" object and then using the "load" method, as follows:
XmlDocument doc = new XmlDocument (); / / load the specified XML document doc.Load ("C:\\ data.xml")
2.C# reads the XML file and displays:
In the program of this article, some "XmlNodeReader" attributes, such as "NodeType" attributes, are used to determine what type of read get node is. "Value" is the value of the node.
While (reader.Read ()) {/ / determine the current read acquisition node type switch (reader.NodeType) {case XmlNodeType.Element: s = reader.Name; break; case XmlNodeType.Text: if (s.Equals ("Name")) myItem = Listview1.Items.Add (reader.Value); else myItem.SubItems.Add (reader.Value); break }} Thank you for your reading, the above is the content of "A brief introduction to reading XML files in C#". After the study of this article, I believe you have a deeper understanding of the problem of reading XML files in C#, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.