C × XML base XElement Name the first level child node name of the root node

Keywords: xml github Windows encoding

  • .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"?>
  <taoists count="100" comment="good-t">
      <name>The Scripture of Ethics</name>
      <author>Lao Tzu</author>
      <name>Wen Cheng Jing Jing</name>
      <author>Guan Yin Zi</author>
  <buddhism count="321" comment="good-d">
      <name>Diamond Sutras</name>
      <author>Shakya Muni</author>
      <name>Platform Sutra</name>
      <author>Hui Neng</author>


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 xle = file.Root;

            IEnumerable<XElement> ixt = xle.Elements();

            foreach (var item in ixt)





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.

Posted by ShashidharNP on Fri, 08 Nov 2019 13:08:17 -0800