I have a requirement to retrieve AmountRequired depending on the category from the below input and list out all the repeated elements.
<root>
<Unspecified>
<Category>T03</Category>
<AmountRequired>993</AmountRequired>
<ExcessAmount>250</ExcessAmount>
<Currency>GBP</Currency>
<ExchangeRate>1</ExchangeRate>
</Unspecified>
<Unspecified>
<Category>T03</Category>
<AmountRequired>9903</AmountRequired>
<ExcessAmount>250</ExcessAmount>
<Currency>GBP</Currency>
<ExchangeRate>1</ExchangeRate>
</Unspecified>
<Unspecified>
<Category>P02</Category>
<AmountRequired>992</AmountRequired>
<Currency>GBP</Currency>
<ExchangeRate>1</ExchangeRate>
</Unspecified>
<Unspecified>
<Category>A29</Category>
<AmountRequired>929</AmountRequired>
<Currency>GBP</Currency>
<ExchangeRate>1</ExchangeRate>
</Unspecified>
</root>
I want to get the out put as below. When there are 2 tags of T03 its should display both the amounts as below. Also if a Category doesn't exist it doesn't for example P05 and if we have the transformation for it then it errors out that P05 doesn't exist, so is there a way to get over the error even if the input xml doesn't contain the P05 Category?
<amountRequired>
<amount>929</amount>
<currency>GBP</currency>
<exchangeRate>1</exchangeRate>
<amountInSystemCurrency>550</amountInSystemCurrency>
</amountRequired>
<amountRequired>
<amount>993</amount>
<currency></currency>
<exchangeRate></exchangeRate>
<amountInSystemCurrency></amountInSystemCurrency>
</amountRequired>
<amountRequired>
<amount>9903</amount>
<currency></currency>
<exchangeRate></exchangeRate>
<amountInSystemCurrency></amountInSystemCurrency>
</amountRequired>
<amountRequired>
<amount>992</amount>
<currency></currency>
<exchangeRate></exchangeRate>
<amountInSystemCurrency></amountInSystemCurrency>
</amountRequired>
Highly appreciate any help with this