XML, XPATH adding values

Posted by user575373 on Stack Overflow See other posts from Stack Overflow or by user575373
Published on 2011-01-14T08:28:04Z Indexed on 2011/01/14 8:53 UTC
Read the original article Hit count: 272

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml