首页 > 其他 > 详细

XML一小节

时间:2015-09-14 15:26:31      阅读:283      评论:0      收藏:0      [点我收藏+]
先上自己的代码笔记
using
System; using System.Collections.Generic; using System.IO; using System.Xml; namespace ConsoleApplication7 { class Program { static void Main(string[] args) { ////代码的路径 string xmlPath = @"D:\xmltests\test.xml"; if(File.Exists(xmlPath))//该xml文件是否存在 { Console.WriteLine(" The XML Exist!"); //读取 XmlDocument xmlDoc = new XmlDocument(); //加载路径里面的内容 xmlDoc.Load(xmlPath); //获取子节点 XmlNodeList list = xmlDoc.SelectSingleNode("Luna").ChildNodes; foreach(XmlElement xe in list) {//开始遍历 if(xe.Name=="days") { Console.WriteLine("The Element Exist!!!"); foreach(XmlElement day in xe) {//遍历子节点的子节点 if(day.Name=="day1") { Console.WriteLine(day.InnerText); } } } } } } } }

 

XML一小节

原文:http://www.cnblogs.com/SunBool/p/4807108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!