1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      LINQToXML怎么使用

      這篇文章主要講解了“LINQ To XML怎么使用”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“LINQ To XML怎么使用”吧!

      創(chuàng)新互聯(lián)建站成都企業(yè)網(wǎng)站建設服務,提供網(wǎng)站設計制作、成都網(wǎng)站建設網(wǎng)站開發(fā),網(wǎng)站定制,建網(wǎng)站,網(wǎng)站搭建,網(wǎng)站設計,成都響應式網(wǎng)站建設公司,網(wǎng)頁設計師打造企業(yè)風格網(wǎng)站,提供周到的售前咨詢和貼心的售后服務。歡迎咨詢做網(wǎng)站需要多少錢:18980820575

      LINQ To XML——XML操作

      XML數(shù)據(jù)越來越廣泛地應用在各種實際的開發(fā)系統(tǒng)中,為了簡化對XML數(shù)據(jù)的開發(fā)和利用,微軟的開發(fā)團隊開發(fā)了這個全新的LINQ to XML框架。首先,LINQ to XML框架是一個輕量級的XML編程API,開發(fā)者利用該框架,幾乎可以取代原有的XML數(shù)據(jù)開發(fā)方式,非常簡單地創(chuàng)建、讀取并操作內存中的XML數(shù)據(jù),如利用函數(shù)構造方法創(chuàng)建XML樹等。其次,LINQ to XML框架中集成了LINQ的強大功能,開發(fā)者可以采用一致的編程方式,非常容易地操作并查詢XML數(shù)據(jù)。

      XElement Students = new XElement("Students",  new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age", 20)),  new XElement("Student",  new XElement("Name", "李四"),  new XElement("Sex", "女"),  new XElement("Age", 19))  );  Console.WriteLine(Students);  編歷XML  XElement Students = new XElement("Students",  new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age", 20)),  new XElement("Student",  new XElement("Name", "李四"),  new XElement("Sex", "女"),  new XElement("Age", 19))  );  foreach (XNode node in Students.Nodes())  {  Console.WriteLine(node);  Console.WriteLine("----------------------------");  }  foreach (XElement ele in Students.Elements())  {  Console.WriteLine(ele);  Console.WriteLine("********************************");  }

      添加XML節(jié)點

      XElement Students = new XElement("Students",   new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age", 20)),  new XElement("Student",  new XElement("Name", "李四"),  new XElement("Sex", "女"),  new XElement("Age", 19))  );  foreach (XElement ele in Students.Elements())  {  ele.Element("Age").AddAfterSelf(new XElement("Hight", 173));  ele.Element("Age").AddBeforeSelf(new XElement("Weight", 73));  ele.Add (new XElement("Hobby", "Coding"));  }  Console.WriteLine(Students)  更新XML節(jié)點  XElement Students = new XElement("Students",  new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age",new XAttribute ("Year",1989/8/22), 20))  );  Students.Element(“Student”).Element(“Age”).ReplaceWith(new XElement(“Age”, 28));//替換掉整個節(jié)點  // Students.Element(“Student”).Element(“Age”).ReplaceNodes ( 28);//只替換節(jié)點值  // Students.Element(“Student”).Element(“Age”).ReplaceAll (28);//替換掉整個節(jié)點  Console.WriteLine(Students);  刪除XML節(jié)點  XElement Students = new XElement("Students",  new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age",new XAttribute ("Year","1989/8/22"), 20))  );  //Students.Element("Student").Element("Age").Remove ();//移除節(jié)點  //Students.Element("Student").Element("Age").RemoveAll();//移除節(jié)點的值和屬性  Students.Element("Student").Element("Age").RemoveNodes();//移除節(jié)點的值  Console.WriteLine(Students);  添加XML屬性  XElement Students = new XElement("Students",  new XElement("Student",  new XElement("Name", "張三"),  new XElement("Sex", "男"),  new XElement("Age",new XAttribute ("Year","1989/8/22"), 20))  );  Students.Element("Student").SetAttributeValue("dd","dddd");  Console.WriteLine(Students);  更新XML屬性  Students.Element("Student").Element("Age").ReplaceAttributes(new XAttribute("Year","dd"));  Students.Element("Student").Element("Age").SetAttributeValue("Year", "dddd");  刪除XML屬性  Students.Element("Student").Element("Age").Attribute("Year").Remove ();  Students.Element("Student").Element("Age").RemoveAttributes ();  遍歷XML屬性  var Attr = from att in Students.Element("Student").Element("Age").Attributes()  select att;  foreach (var att in Attr)  {  Console.WriteLine(att);  }

      感謝各位的閱讀,以上就是“LINQ To XML怎么使用”的內容了,經過本文的學習后,相信大家對LINQ To XML怎么使用這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關知識點的文章,歡迎關注!


      網(wǎng)站題目:LINQToXML怎么使用
      標題URL:http://www.ef60e0e.cn/article/pidcii.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        阿拉善左旗| 丹东市| 咸宁市| 小金县| 沧州市| 威海市| 荔浦县| 德格县| 巩义市| 遵化市| 象州县| 左权县| 松江区| 石河子市| 城口县| 新源县| 滨海县| 平原县| 兖州市| 日喀则市| 巧家县| 景泰县| 略阳县| 锦屏县| 普兰县| 运城市| 侯马市| 玉溪市| 安国市| 颍上县| 灵宝市| 通山县| 突泉县| 翼城县| 桐柏县| 大兴区| 色达县| 博罗县| 独山县| 宜宾县| 阿克苏市|