I have a big xml file with little formatting in it. It contains over 600 messages that I need to break each message out in its own separate file.
The xml file looks in the middle of it something like this:
</Title></Msg><Msg><Opener> Hello how
are you?<Title> Some says hello</Title><Body>
This is a test to see how everything is
going. I need your help.</Body></Msg><Msg>
<Open1> An opening.</Open1><Title> Trying
something new.</Title><Report>124555ABC
</Report><Body> Another test for me.</Body>
<PS> I need to figure this out.</PS></Msg>
<Msg> etc........ etc... etc..
.......etc. .......
Some caveats:
- The messages always start with <Msg>
- The messages always ends with </Msg>
- The <Msg> could be at the beginning, middle or end of a line.
- The </Msg> could be at the beginning, middle or end of a line.
- There can be different amount of tag in a line i.e. <Title><Body>,etc...
- Message could be one to 100+ lines long.
Any suggestion on breaking each message from this xml file into its own file. Any sed/awk/nawk shell function/statements would be appreciated.
In the end, there is 600+ messages so there should be 600+ files.
Thank you.