input xml file
<ARS>
<tag1>one</tag1>
<tag2>two</tag2>
<tag3>three<AltError Code=123 Description=456789/></tag3>
<tag4>four</tag4>
<ARS>
<ARS>
<tag1>ABCD</tag1>
<tag2>ABCD</tag2>
<tag3>ddsdsds<AltError Code=123 Description=456789/></tag3>
<tag4>EFGH<AltError Code=abc Description=defg/></tag4>
<ARS>
Expected Output:
tag1|tag2|tag3|tag4|code|Description
one|two|three|four|123|456789
ABCD|ABCD|ddsdsds|123|456789
ABCD|ABCD|ddsdsds|abc|defg
The script should read this file and create a pipe delimited file. Each ARS tag record in the XML file should create one line in the target. Get all the values enclosed within the tags, which are the column values.
Also if suppose an <AtlError> encounters within an ARS tag, then get the Code and Description values of the AltError tag and append it to the last of that particular ARS record. If suppose 2 AltError encounters within an ARS tag, the target should be having 2 records.
Can someone please help me out