c#通过xpath读取xml示例

前端技术 2023/09/03 C#

需要修改Main方法第一行代码的路径为你的books.xml文件绝对路径或相对路径。代码演示了XPath各种语法的使用情况

books.xml

复制代码 代码如下:

<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<bookstore>

  <book category=\"COOKING\">
    <title lang=\"en\">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>

  <book category=\"CHILDREN\">
    <title lang=\"en\">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>

  <book category=\"WEB\">
    <title lang=\"en\">XQuery Kick Start</title>
    <author>James McGovern</author>
    <author>Per Bothner</author>
    <author>Kurt Cagle</author>
    <author>James Linn</author>
    <author>Vaidyanathan Nagarajan</author>
    <year>2003</year>
    <price>49.99</price>
  </book>

  <book category=\"WEB\">
    <title lang=\"en\">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
  </book>

</bookstore>

本文地址:https://www.stayed.cn/item/7802

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。