Calculating the total from identical tags



Please advise on how I achieve the following transformation.


The input xml I have is of the format.



<Employees>
<Employee>
<Name>Don</Name>
<Salary>5000</Salary>
<Expense>1000</Expense>
<Expense>500</Expense>
<Expense>300</Expense>
</Employee>
<Employee>
<Name>John</Name>
<Salary>5000</Salary>
<Expense>100</Expense>
<Expense>400</Expense>
<Tax>500</Tax>
<Tax>200</Tax>
</Employee>


And the output should be



<Employees>
<Employee>
<Name>Don</Name>
<Salary>5000</Salary>
<Expense>1800</Expense>
</Employee>
<Employee>
<Name>John</Name>
<Salary>6000</Salary>
<Expense>500</Expense>
<Tax>700</Tax>
</Employee>


Thanks


No comments:

Post a Comment