Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

xml学习(7) .net 获取xml节点或者属性最大值

$
0
0

上一节中,我们介绍了一些xml的xpath属性和函数

下面我们来介绍两个比较特殊的使用:

1.获取相同节点的最大值

2.获取相同节点某属性最大值



xmlName为“内容”

1.获取相同节点的最大值

     string fileName = HttpContext.Current.Request.PhysicalApplicationPath + "\\Xml\\" + xmlName + ".xml";//xml的物理路径
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(fileName);
      
            XmlNode fdfdf = xmlDoc.SelectSingleNode("//rows[not(.<//rows)]");
2.获取相同节点某属性最大值

   string fileName = HttpContext.Current.Request.PhysicalApplicationPath + "\\Xml\\" + xmlName + ".xml";//xml的物理路径
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(fileName);
            XmlNode maxNodejj = xmlDoc.SelectSingleNode("//rows/@ID[not(.<//rows/@ID)]");

下面是内容.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
  <Header ID="ID" class="class" class_name="class_name" year="year" school="school" count="count">2
  </Header>
  <rows ID="01" class="一五班" class_name="实验班" year="2013" school="三峡高级中学" count="30">4
  </rows>
  <rows ID="02" class="一六班" class_name="奥数班" year="2013" school="三峡高级中学" count="25">9
  </rows>
  <rows ID="03" class="一七班" class_name="阳光班" year="2013" school="三峡高级中学" count="69">8
  </rows>
</config>




作者:yucihai 发表于2013-12-1 2:54:00 原文链接
阅读:109 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>