I have a requirement to read the xml file and split the files into two diffrent files in Unix shell script. Could anyone please help me out with this requirement.
Sample file
---------------
0,<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s>
<Name>aaa</Name>
<age>12</age>
</s>
</Information>,<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><s>
<Name>aaa</Name><age>12</age></s></Information>
1,<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s>
<Name>bbb</Name>
<age>12</age>
</s>
</Information>,<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><s>
<Name>bbb</Name><age>12</age></s></Information>
---------------
Expected output:
output1.xml
---------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s>
<Name>aaa</Name>
<age>12</age>
</s>
</Information>
---------------
Output2.xml
---------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><s>
<Name>aaa</Name><age>12</age></s></Information>
---------------
After processing the file output1.xml and output2.xml the files need to be purged.
The second line of the sample file has to be read and written to the output1.xml and output2.xml file that is created during this process
Expected output:
output1.xml
---------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s>
<Name>bbb</Name>
<age>12</age>
</s>
</Information>
---------------
Output2.xml
---------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><s>
<Name>bbb</Name><age>12</age></s></Information>
---------------
The sample file has to be processed for the whole file in looping process.
Could anyone help me to resolve this?
Thanks in Advance
Krishnakanth Manivannan