Sorry, but your "rules" are not clear. You need to do a better job of explaining them. Are 'A' and 'B' actual values or do they just represent some other values? Maybe a more extensive and/or realistic example would help.
This needs to be formatted as,
Basically I want the start and end tag to be on the same record. If you note the above example, in cases where the end tags are not on the same record, I am extracting the end tag and appending it to the start tag.
Thanks a lot Frank. But there is one more condition which I should have put this on my earlier post. Your code would just stick a </SETONE> or </SETTWO> or </XMLFILE> when there is no '</' in the entire record.
It sounds like you need to define the "rules" for your error checking and implement them with a program. I don't know how much error checking you want to do, what you would consider to be an error, or if "abending" means issuing a particular error message or just terminating with any old message. To get that kind of control usually requires writing a program with the needed logic.