escape XML entities to fix xmlParseEntityRef issue