成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

LINQ To XML定位方法

開發 后端
這里介紹LINQ To XML——定位方法,包括Ancestors:返回指定節點的所有上級元素、Descendants:返回所有指定元素名稱的后續所有相同元素集合等方面。

LINQ有很多值得學習的地方,這里我們主要介紹LINQ To XML,包括介紹LINQ To XML——定位方法等方面。

LINQ To XML定位方法

1.LINQ To XML定位方法——Ancestors:返回指定節點的所有上級元素。(AncestorsAndSelf:返回包括自己的所有上級元素)

  1. XElement Students = new XElement("Students",  
  2. new XElement("Student"  
  3. new XElement("Name", "張三"),  
  4. new XElement("Sex", "男"),  
  5. new XElement("Age",new XAttribute ("Year","1989/8/22"), 20))  
  6. );  
  7. foreach (var el in Students.Element ("Student").Element("Sex").Ancestors ())  
  8. {  
  9. Console.WriteLine(el);  

2.LINQ To XML定位方法——Descendants:返回所有指定元素名稱的后續所有相同元素集合。

  1. XElement Students = new XElement("Students",  
  2. new XElement("Student",  
  3. new XElement("Name", "張三"),  
  4. new XElement("Sex", "男"),  
  5. new XElement("Age", new XAttribute("Year", "1989/8/22"), 20)),  
  6. new XElement("Student",  
  7. new XElement("Name", "李四"),  
  8. new XElement("Sex", "女"),  
  9. new XElement("Age", new XAttribute("Year", "1990/8/22"), 20))  
  10. );  
  11. foreach (var v in Students.Descendants())  
  12. {  
  13. Console.WriteLine(v);  
  14. Console.WriteLine("-----------------------");  

3.LINQ To XML定位方法——ElementsAfterSelf:返回當前節點后的所有節點。(ElementsBeforeSelft:返回當前節點前的所有節點)

  1. XElement Students = new XElement("Students",  
  2. new XElement("Student",  
  3. new XElement("Name", "張三"),  
  4. new XElement("Sex", "男"),  
  5. new XElement("Age", new XAttribute("Year", "1989/8/22"), 20)),  
  6. new XElement("Student",  
  7. new XElement("Name", "李四"),  
  8. new XElement("Sex", "女"),  
  9. new XElement("Age", new XAttribute("Year", "1990/8/22"), 20))  
  10. );  
  11. foreach (var v in Students.Element ("Student").ElementsAfterSelf ())  
  12. {  
  13. Console.WriteLine(v);  
  14. Console.WriteLine("-----------------------");  
  15. }

【編輯推薦】

  1. LINQ查詢操作剖析
  2. LINQ生成字符串概述
  3. LINQ查詢語法簡單描述
  4. LINQ解決方案簡單概述
  5. LINQ查詢結果分析
責任編輯:佚名 來源: CSDN
相關推薦

2011-07-22 08:43:08

XML

2009-09-17 13:54:26

LINQ to XML

2009-09-17 13:30:32

LINQ to XML

2009-01-04 16:58:48

LINQ to XMLLINQXML

2009-09-16 16:59:05

LINQ to XML

2009-09-14 16:46:15

LINQ to XML

2009-09-14 15:12:40

LINQ to XML

2009-09-16 15:33:22

LINQ to XML

2009-09-16 16:52:50

LINQ to XML

2011-07-26 13:58:17

LINQ

2009-09-08 16:55:01

Linq實現XML轉換

2009-09-16 15:41:45

LINQ查詢XML文檔

2009-09-16 16:55:07

LINQ to XML

2009-09-14 16:33:55

LINQ To XML

2009-09-14 16:17:03

什么是LINQ To

2009-09-16 15:48:05

Linq修改XML文檔

2009-09-16 15:53:49

Linq創建xml文檔

2009-09-17 13:38:42

LINQ to XML

2009-09-14 14:58:52

LINQ to XML

2009-09-14 15:45:28

LINQ刪除XML節點
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 一区二区在线免费观看 | 国产丝袜av | 二区三区av | 免费a级毛片在线播放 | 丁香婷婷在线视频 | 中文字幕国产 | 精品欧美黑人一区二区三区 | 久久成| 在线观看国产wwwa级羞羞视频 | 亚洲精品永久免费 | 免费人成在线观看网站 | 久久久久国产一区二区三区四区 | www.五月婷婷.com | 日韩成人一区二区 | 久久久精品网站 | 国产日韩精品视频 | 日本一区二区视频 | 不卡一区二区三区四区 | 日本精品视频 | 免费看色 | 激情五月婷婷 | 黄色网址av | 国产一区二区三区四区五区加勒比 | 成人亚洲网站 | 在线成人| 精品欧美一区二区三区久久久 | 国产精品久久久久无码av | 黄色在线免费观看视频 | 国产精品99久久久久久大便 | av毛片 | 成人亚洲一区 | 韩国久久精品 | 国产精品日韩 | 久久精彩 | 365夜爽爽欧美性午夜免费视频 | 国产在线不卡视频 | 激情综合五月 | 日本人做爰大片免费观看一老师 | 在线成人av| 色综合久 | 成人h视频 |