Why do you want to escape those characters? Just store the document in the DB2 database as-is. Or do you want to break down/piece together an XML document from strings without the DB2 XML functionality? (I don't know if that was available in DB2 z/OS V8.)