I need help to transpose XML from Rows Into Elements in XML output.
I listed below the source and expected XMLs. There can be multiple instances of <Pay_Result_Lines_group> with most just have <Tax_Order> of 99. The output XML is sorted based on <Tax_Order> that would be 1-4 or 99. For those instances with order 99, they will be put under <Tax_5_Desc>, <Tax_6_desc>, <Tax_7_Desc>,... <Tax_n_Desc> till how many of them in source XML.
The source XML is below:
<Report_Entry>
<Account_ID>123456</Account_ID>
<Pay_Result_Lines_group>
<Tax_N_Description>W_FWFEDERAL</Tax_N_Description>
<Tax_N_Rate>0</Tax_N_Rate>
<Tax_Order>1</Tax_Order>
</Pay_Result_Lines_group>
<Pay_Result_Lines_group>
<Tax_N_Description>W_MEDFEDERAL</Tax_N_Description>
<Tax_N_Rate>0.0145</Tax_N_Rate>
<Tax_Order>2</Tax_Order>
</Pay_Result_Lines_group>
<Pay_Result_Lines_group>
<Tax_N_Description>W_OASFEDERAL</Tax_N_Description>
<Tax_N_Rate>0.062</Tax_N_Rate>
<Tax_Order>4</Tax_Order>
</Pay_Result_Lines_group>
<Pay_Result_Lines_group>
<Tax_N_Description>W_SUI34</Tax_N_Description>
<Tax_N_Rate>0.003825</Tax_N_Rate>
<Tax_Order>99</Tax_Order>
</Pay_Result_Lines_group>
<Pay_Result_Lines_group>
<Tax_N_Description>W_NJFAMNJFLI</Tax_N_Description>
<Tax_N_Rate>0.0008</Tax_N_Rate>
<Tax_Order>99</Tax_Order>
</Pay_Result_Lines_group>
<Pay_Result_Lines_group>
<Tax_N_Description>W_NJWDNJ-WDF</Tax_N_Description>
<Tax_N_Rate>0.000425</Tax_N_Rate>
<Tax_Order>99</Tax_Order>
</Pay_Result_Lines_group>
</Report_Entry>
The expected output is below:
<Workers>
<Worker>
<Account_ID>123456</Account_ID>
<Tax_1_Desc>W_FWFEDERAL</Tax_1_Desc>
<Tax_1_Rate/>
<Tax_2_Desc>W_MEDFEDERAL</Tax_2_Desc>
<Tax_2_Rate/>
<Tax_4_Desc>W_OASFEDERAL</Tax_4_Desc>
<Tax_4_Rate/>
<Tax_5_Desc>W_SUI34</Tax_5_Desc>
<Tax_5_Rate/>
<Tax_6_Desc>W_NJFAMNJFLI</Tax_6_Desc>
<Tax_6_Rate/>
<Tax_7_Desc>W_NJWDNJ-WDF</Tax_7_Desc>
<Tax_7_Rate/>
</Worker>
</Workers>