XML : How to get all child element names and values inside a particular element in an XML tag

I have a string in the form of a XML with a number of tags :

  <Code>  <!-- Schema Version MQ Message blocks -->      <T_C_B>          < ATXYCB>ABC11</ ATXYCB>          <BTCWZB>EFG22</BTCWZB>          < CTATCB>IJK33</CTATCB>          < DTCAAB>LMN44</DTCAAB>          <!-- End T_C_B -->      </T_C_B>        <D_C_B>          < ADCB>xs:string</ ADCB>          < BDCB>xs:string</ BDCB>          < CDCB>xs:string</ CDCB>      <!-- End D_ C_B-->      </D_C_B>      <U_C_B>          <UATXYCB>AA2B</ UATXYCB>          <BUTCWZB>BB4C</BUTCWZB>          < UCTATCB>C8CD</UCTATCB>          < DTUCAAB>D9DE</DTUCAAB>      <!-- End U_C_B->      </U_C_B>  </Code>    

I need to find elements inside T_C_B and U_C_B and their values and concatenate with a delimitter like "|" :

ATXYCB=ABC11|BTCWZB=EFG22|CTATCB=IJK33|DTCAAB=LMN44|UATXYCB=AA2B|etc……”

Is there any Regex that can be used...?? Or any other work around

No comments:

Post a Comment