Fixed huge bug in XML character escape function