后端开发|C#.Net教程
c#,XML,子节点
后端开发-C#.Net教程
本文主要介绍了c#读取XML多级子节点的方法。具有很好的参考价值。下面跟着小编一起来看下吧
源码 vs,ubuntu必要的安装,爬虫软件工作原理,php fontfile,SEO总结查询lzw
话不多说,请看代码:
html5自适应手机源码,ubuntu开机如何加快,tomcat服务器启动过慢,爬虫3小时,php论坛网站设计开题报告,哈尔滨seo方案lzw
string xmlFilePath = "D:\\log_xml\\MarInfo.xml"; //Server.MapPath(@"相对路径如/xml/test.xml");XmlDocument doc = new XmlDocument();doc.Load(xmlFilePath);//加载XML文件string rst = "";//使用xpath表达式选择文档中所有的student子节点XmlNodeList studentNodeList = doc.SelectNodes("Root/MarketList/Market");if (studentNodeList != null){foreach (XmlNode studentNode in studentNodeList){//通过Attributes获得属性名字为name的属性string name = studentNode.Attributes["MarketName"].Value+":";rst+= name;//通过SelectSingleNode方法获得当前节点下的SubMarketList子节点XmlNode coursesNode = studentNode.SelectSingleNode("SubMarketList");//通过ChildNodes属性获得courseNode的所有一级子节点XmlNodeList courseNodeList = coursesNode.ChildNodes;if (courseNodeList != null){foreach (XmlNode courseNode in courseNodeList){rst += courseNode.Attributes["Name"].Value+",";}rst += "
";}}}Response.Write(rst);
android 日历控件源码,vscode启动谷歌特别慢,ipad跑ubuntu,tomcat窗口的名称,爬虫新工具,php 姓名星号,黄冈seo优化要做什么,php商务网站开发代码,自适用手机html模板lzw