- .NET Framework : 4.7.2
- IDE : Visual Studio Community 2019
- OS : Windows 10 x64
- typesetting : Markdown
- blog : blog.csdn.net/yushaopu
- github : github.com/GratefulHeartCoder
xml file
<?xml version="1.0" encoding="utf-8"?> <cultures> <taoists count="100" comment="good-t"> <book> <name>The Scripture of Ethics</name> <author>Lao Tzu</author> </book> <book> <name>Wen Cheng Jing Jing</name> <author>Guan Yin Zi</author> </book> </taoists> <buddhism count="321" comment="good-d"> <book> <name>Diamond Sutras</name> <author>Shakya Muni</author> </book> <book> <name>Platform Sutra</name> <author>Hui Neng</author> </book> </buddhism> </cultures>
code
using System; using System.Collections.Generic; using System.Xml.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { // The format of xml file must be correct XDocument file = XDocument.Load("MyXMLFile.xml"); // Get the root node of the xml file XElement xmlRoot = file.Root; // Get the first level child node under the root node IEnumerable<XElement> nodeFirst = xmlRoot.Elements(); foreach (var item in nodeFirst) { Console.WriteLine("+"); // nodesecond is a child of the first level child var nodeSecond = item.Elements(); foreach (var node in nodeSecond) { Console.WriteLine(" -"); Console.WriteLine(node); } } Console.ReadKey(); } } }
result
+ - <book> <name>The Scripture of Ethics</name> <author>Lao Tzu</author> </book> - <book> <name>Wen Cheng Jing Jing</name> <author>Guan Yin Zi</author> </book> + - <book> <name>Diamond Sutras</name> <author>Shakya Muni</author> </book> - <book> <name>Platform Sutra</name> <author>Hui Neng</author> </book>
resource
- [document] docs.microsoft.com/zh-cn/dotnet/csharp
- [Specification] github.com/dotnet/docs/tree/master/docs/standard/design-guidelines
- [document XML] www.w3school.com.cn/x.asp
- [document XML] www.runoob.com/xml/xml-tutorial.html
- [source code] referencesource.microsoft.com
- [platform] www.csdn.net
- [ IDE ] visualstudio.microsoft.com/zh-hans
- [.NET Core] dotnet.github.io
I'm grateful to those who have helped me.
XML, DTD, XML schema, XSL, SVG can be understood properly.
C. excellent, worth learning. . NET Core has the ability of cross platform, which is worthy of attention.
Console,WinForm,WPF,ASP.NET , Azure WebJob, WCF, Unity3d, UWP can be properly understood.
Note: This is a self-study note, the quality of the inferior, so think twice before you go. When a novice comes here, he can't copy it. He should first study its image number, and when he can change it, he will naturally jump out of the pit.