remove invalid XML characters while building document