Kai Hartmann
Kai Hartmann

Reputation: 3154

xsl - select node by child

I have a problem selecting just elements of an xml, which contain a specific child node. Asumme the following part of an xml:

<root>
<Navision.Buchungen>
    <Saldo>-110867.7500</Saldo>
    <Navision.Kontostruktur>
        <Bereich>1</Bereich>
    </Navision.Kontostruktur>
</Navision.Buchungen>
<Navision.Buchungen>
    <Saldo>-3082585.2100</Saldo>
    <Navision.Kontostruktur>
        <Bereich>2</Bereich>
    </Navision.Kontostruktur>
</Navision.Buchungen>
...
</root>

Now I have an xsl part like this to get the sum of 'Saldo':

<xsl:variable name="FACT0" select="sum(//root/Navision.Buchungen/Saldo)"/>

But how can I select just the Saldo for 'Bereich' 1 for example?

Upvotes: 1

Views: 224

Answers (2)

Florian
Florian

Reputation: 390

//root/Navision.Buchungen[Navision.Kontostruktur/Bereich = 1]/Saldo

Edited: oh already posted.

For further problems you can use one of the online testbeds like this one. And of course good manuals like those from w3schools, also with testbeds for xsl

Upvotes: 2

Lukas Eder
Lukas Eder

Reputation: 220762

Use this XPath:

//root/Navision.Buchungen[Navision.Kontostruktur/Bereich = 1]/Saldo

Upvotes: 2

Related Questions