0

例如,我有一个 XML:

    <?xml version="1.0"?>
<list>
    <pos matnr="10017571" charg="1045825700" atwrt="108" labst="610" />
    <pos matnr="10017572" charg="1045825700" atwrt="108" labst="600" />
    <pos matnr="10017573" charg="1046186400" atwrt="108" labst="2730" />
    <pos matnr="10017573" charg="1046117000" atwrt="108" labst="5200" />
    <pos matnr="10017573" charg="1046055000" atwrt="108" labst="3507" />
    <pos matnr="10017574" charg="1045911400" atwrt="108" labst="50" />
    <pos matnr="10017574" charg="1046055000" atwrt="108" labst="14230" />
    <pos matnr="10017574" charg="1046117000" atwrt="108" labst="5500" />
    <pos matnr="10017574" charg="1046186400" atwrt="108" labst="2410" />
</list>

那么,如何在 XPath 中选择具有一个属性的特定值和另一个属性的最大值的节点?我需要这样的东西(不起作用):

xmlDocZ.selectSingleNode("//pos[@matnr='10017574' and @labst[not(.>//@labst)]]");

结果必须是:

<pos matnr="10017574" charg="1046055000" atwrt="108" labst="14230" />
4

1 回答 1

0

哦,我自己弄的。这工作正常:

xmlDocZ.selectSingleNode("//pos[@matnr='10017574' and @labst[not(.//pos[@matnr='10017574']/@labst)]]");
于 2015-04-15T08:32:47.633 回答