中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

C#中通過(guò)xpath查找xml的指定元素

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
orders.xml文檔內(nèi)容如下
<?xml version="1.0"?>
<Order id="2004-01-30.195496">
  <Client id="ROS-930252034">
    <Name>Remarkable Office Supplies</Name>
  </Client>
 
  <Items>
    <Item id="1001">
      <Name>Electronic Protractor</Name>
      <Price>42.99</Price>
    </Item>
    <Item id="1002">
      <Name>Invisible Ink</Name>
      <Price>200.25</Price>
    </Item>
  </Items>
</Order>



//該代碼片段來(lái)自于: http://www.sharejs.com/codes/csharp/7775
C#代碼
using System;
using System.Xml;
 
public class XPathSelectNodes {
    private static void Main() {
 
        // Load the document.
        XmlDocument doc = new XmlDocument();
        doc.Load("orders.xml");
        XmlNodeList nodes = doc.SelectNodes("/Order/Items/Item/Name");
 
        foreach (XmlNode node in nodes) {
            Console.WriteLine(node.InnerText);
        }
 
        Console.ReadLine();
    }
}


//該代碼片段來(lái)自于: http://www.sharejs.com/codes/csharp/7775
輸出結(jié)果
Electronic Protractor
Invisible Ink

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:C#自定義繁體和簡(jiǎn)體字庫(kù)實(shí)現(xiàn)中文繁體和簡(jiǎn)體之間的轉(zhuǎn)換

下一篇: linux shell 備份mysql 數(shù)據(jù)庫(kù)