1

例如,有一个 XML:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <row>
        <Type>1</Type>
        <WeaNr_ArtNr>100027</WeaNr_ArtNr>
        <UID>101114557945</UID>
    </row>
    <row>
        <Type>2</Type>
        <WeaNr_ArtNr>2000311</WeaNr_ArtNr>
        <UID>101114557945</UID>
        <UnitQuantity>10</UnitQuantity>
    </row>
    <row>
        <Type>1</Type>
        <WeaNr_ArtNr>100027</WeaNr_ArtNr>
        <UID>101114557946</UID>
    </row>
<row>
    <Type>2</Type>
    <WeaNr_ArtNr>2000312</WeaNr_ArtNr>
    <UID>101114557946</UID>
    <UnitQuantity>10</UnitQuantity>
</row>
    <row>
        <Type>1</Type>
        <WeaNr_ArtNr>55555</WeaNr_ArtNr>
        <UID>101114558000</UID>
    </row>
    <row>
        <Type>2</Type>
        <WeaNr_ArtNr>200053155555</WeaNr_ArtNr>
        <UID>101114558000</UID>
        <UnitQuantity>1</UnitQuantity>
    </row>
    <row>
        <Type>1</Type>
        <WeaNr_ArtNr>55555</WeaNr_ArtNr>
        <UID>101114558001</UID>
    </row>
    <row>
        <Type>2</Type>
        <WeaNr_ArtNr>200053255555</WeaNr_ArtNr>
        <UID>101114558001</UID>
        <UnitQuantity>1</UnitQuantity>
    </row>
        <row>
        <Type>1</Type>
        <WeaNr_ArtNr>100023</WeaNr_ArtNr>
        <UID>101114557989</UID>
    </row>
    <row>
        <Type>2</Type>
        <WeaNr_ArtNr>2000274</WeaNr_ArtNr>
        <UID>101114557989</UID>
        <UnitQuantity>14</UnitQuantity>
    </row>
    <row>
        <Type>1</Type>
        <WeaNr_ArtNr>100023</WeaNr_ArtNr>
        <UID>101114557990</UID>
    </row>
    <row>
        <Type>2</Type>
        <WeaNr_ArtNr>2000275</WeaNr_ArtNr>
        <UID>101114557990</UID>
        <UnitQuantity>23</UnitQuantity>
    </row>
</root>

通过知道WeaNr_ArtNr案例的价值,Type='1'我想返回下一个节点

例如,对于WeaNr_ArtNr='100027' 我想获取这些节点:

<row>
    <Type>2</Type>
    <WeaNr_ArtNr>2000311</WeaNr_ArtNr>
    <UID>101114557945</UID>
    <UnitQuantity>10</UnitQuantity>
</row>
<row>
    <Type>2</Type>
    <WeaNr_ArtNr>2000312</WeaNr_ArtNr>
    <UID>101114557946</UID>
    <UnitQuantity>10</UnitQuantity>
</row>

因为这些节点在节点之后WeaNr_ArtNr='100027'

我试过这样的东西

/root/row[WeaNr_ArtNr='100023']/preceding::row[WeaNr_ArtNr!='100023']

但它不起作用......

4

1 回答 1

1

因此,您希望每一行紧随其后的行WeaNr_ArtNr='100027'?那么怎么样

/root/row[WeaNr_ArtNr='100027']/following-sibling::row[1]
于 2013-08-01T11:41:55.140 回答