Read data in XML file

Hello Everybody,

I have a question on reading the data from XML file through KSH shell script. In the below file I need to collect the patient control no and its respective insured id. I need to have pair of these values in single line separated by some special character, so that I could use them later.

Kindly guide me on how to do this.

<batch status-category="A1">
              <billing-provider-npi>1871606764</billing-provider-npi>
              <total-claims>155</total-claims>
              <total-charges>110048.85</total-charges>
              <claim status-category="A3">
                <error>
                  <error-message>Loop: 2010BC_LOOP Subscriber ID not found on payer file</error-message>
                  <error-record>NM1</error-record>
                  <error-field>09::0067</error-field>
                  <error-code>H241</error-code>
                  <field-contents>ZWP9901514901</field-contents>
                </error>
                <patient-control-no>02G21968276-1</patient-control-no>
                <service-from>20090825</service-from>
                <total-charges>662.00</total-charges>
                <insured-id>ZWP9901514901</insured-id>
              </claim>
              <claim status-category="A3">
                <error>
                  <error-message>Loop: 2010BC_LOOP Subscriber ID not found on payer file</error-message>
                  <error-record>NM1</error-record>
                  <error-field>09::0067</error-field>
                  <error-code>H241</error-code>
                  <field-contents>ZWP800999146</field-contents>
                </error>
                <patient-control-no>02G21968151-1</patient-control-no>
                <service-from>20090824</service-from>
                <total-charges>58.00</total-charges>
                <insured-id>ZWP800999146</insured-id>
              </claim>
              <claim status-category="A1">
                <patient-control-no>02G21983647-1</patient-control-no>
                <service-from>20090827</service-from>
                <total-charges>61.00</total-charges>
                <insured-id>ZWE88003319201</insured-id>
              </claim>
 

Expecting:
02G21968276-1|ZWP9901514901
02G21968151-1|ZWP800999146

PS: I'm trying to use the commands given in other threads too....
Advance thanks.

Regards,
Swami

Try this:

awk -F"<|>" '
/patient-control/{printf("%s|", $3)}
/insured-id/{printf("%s\n", $3)}
' file

Regards

Wow, terrific.... Thanks Franklin52
BTW, I'm trying to learn how it works....