国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

LinqToXML~讀XML文件續

2019-11-17 03:22:44
字體:
來源:轉載
供稿:網友

LinqToxml~讀XML文件續

上篇文章讀了如何通過linq to xml去讀取XML文件,而這講主要通過linq to xml來讀取由屬性組件的XML文件,例如讀取一個web.config的XML格式的配置文件,下面是config文件的部分內容:

<?xml version="1.0" encoding="utf-8" ?><configuration>  <configSections>    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />    <section name="unity" type="Microsoft.PRactices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />  </configSections></configuration>

下面是linq to xml的代碼:

            #region LinqtoXML測試2            System.Console.WriteLine("Loading XML data2...");            var dataXml =                (from e in XElement.Load("D://config.xml")                                   .Element("configSections")                                   .Elements("section")                 select new                     {                         name = (string)e.Attribute("name"),                         type = (string)e.Attribute("type"),                     }).ToList();            dataXml.ForEach(i => System.Console.WriteLine(i.name + "    " + i.type));            #endregion

我們看一下結果:

基本上,對于XML文件的讀取也就是兩種類型了,下講我們將會講一下如何對兩種XML文件進行插入。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太康县| 长治县| 武川县| 漠河县| 札达县| 金川县| 赤峰市| 丹棱县| 当雄县| 防城港市| 马山县| 鹤峰县| 灵丘县| 汪清县| 宁安市| 蛟河市| 留坝县| 紫金县| 万宁市| 海门市| 宜春市| 宣武区| 平遥县| 白河县| 郯城县| 阿瓦提县| 洛宁县| 合水县| 南投县| 乾安县| 安丘市| 蓬莱市| 水富县| 宜兰县| 南部县| 喀喇沁旗| 山丹县| 临湘市| 裕民县| 巴林右旗| 陇西县|