XML, XPATH adding values
- by user575373
hello,
i have XML files which contain records with the following structure:
<payment contractType="1">
<income type="0">
<gr code="1" amount="1506.00"/>
<gr code="4" amount="35.00"/>
<gr code="10" amount="288.14"/>
<de code="3011300" amount="138.72"/>
<de code="3081100" amount="48.81"/>
<de code="3082400" amount="109.84"/>
</income>
<netAmount1 value="765.00"/>
<netAmount2 value="765.00"/>
</payment>
each file has many records of type payment and i want the final xml to contain one payment
record by adding all the amount values for every differrent code value
I think XPath can be used for this, but I never used it before , could someone show me some Java (or else) code for this?