Updating the XML attribute values based on attribute by using VB.Net

  • Thread starter Thread starter RamiReddy.com
  • Start date Start date
R

RamiReddy.com

Guest
Below is the my original XML file and requirement details.

<?xml version="1.0" encoding="utf-8"?>
<Payments>
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="" P7="20" P8="20" />
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="-" P7="10" P8="10" />
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="" P7="30" P8="30" />
<P P1="492" P2="BTX" P3="492V" P4="2" P5="B" P6="" P7="50" P8="50"/>
</Payments>

I am looking for:

  • Based on P4 attribute value we need sum the P7 amount values and update in First record, also need to consider the P6 sign value. If P6 value is - (minus) we need to deduct the amount.
  • Example: For P4 1 we need sum the amounts ($20-10+30) = $40.
  • Also, once we calculated the amounts we need to update the amounts as 0 for remaining all records (for remaining duplicate records).

I am attaching the expected result as:

<?xml version="1.0" encoding="utf-8"?>
<Payments>
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="" P7="40" P8="20" />
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="-" P7="0" P8="10" />
<P P1="492" P2="BTX" P3="492V" P4="1" P5="A" P6="" P7="0" P8="30" />
<P P1="492" P2="BTX" P3="492V" P4="2" P5="B" P6="" P7="50" P8="50"/>
</Payments>


Could you please look into this. Let me know if you need any further details.


Thank you in advance.

Continue reading...
 
Back
Top