XPath来获得最高的ID元素元素、最高、XPath、ID

由网友(既见君子)分享简介:XML源:<文件><文件>< ID>第3版; / ID>< /文件><文件>< ID> 7< / ID>< /文件><文件>< ID> 1< / ID>< /文件>&...

XML源:

 <文件>
    <文件>
        < ID>第3版; / ID>
    < /文件>
    <文件>
        < ID> 7< / ID>
    < /文件>
    <文件>
        < ID> 1< / ID>
    < /文件>
< /文件>
 

我需要在的文档元素,在它的id元素的最高值(让<文件>< ID> 7< / ID>< /文件&GT ; 中的例子)。我不能改变C#code,它是 XMLDocument.SelectSingleNode(...),我只能修改使用的XPath。

有什么样文件/文件[ID = MAX(ID)] 或如按id降序排列得到它?

解决方案

 文件/文件[不(../文件/ ID> ID)]
 
xpath怎样解析网页呢,xpath怎样获取网页的内容

XML Source:

<documents>
    <document>
        <id>3</id>
    </document>
    <document>
        <id>7</id>
    </document>
    <document>
        <id>1</id>
    </document>
</documents>

I need the document-element with the highest value in its id-element (so <document><id>7</id></document> in the example). I can't change the C# code, it is XMLDocument.SelectSingleNode(...), I only can modify the XPath used.

Is there something like documents/document[id=max(id)] or like order by id descending to get it?

解决方案

documents/document[not(../document/id > id)]

阅读全文

相关推荐

最新文章