可扩展标识语言XML
自己定义节点
<?xml version="1.0" encoding="UTF-8"?> <message> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> </message> |
程序示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; using System.Xml; namespace ConsoleApplication9 { class { static { XmlDocument xml = new xml.Load(@"C:\Users\xudajun\Desktop\test\message.xml"); XmlElement xmlroot = xml.DocumentElement; foreach( XmlNode node in xmlroot.ChildNodes ) { foreach(XmlNode list in node.ChildNodes) { switch(list.Name) { case Console.WriteLine(list.InnerText); break; case Console.WriteLine(list.InnerText); break; case Console.WriteLine(list.InnerText); break; case Console.WriteLine(list.InnerText); break; } } } } } } |
执行结果
2021年8月15日