Can I use ESAPI java encoders to encode XML text data? Is there a separate encoder for XML text data? Will there be any discrepancies if I use ESAPI encoders to encode XML text data?
ESAPI has an encoder for XML, see the doc here.
However, if all you need is encoding/decoding, and you don't need all of the functionality provided by ESAPI, I would suggest you use this library instead, as currently ESAPI has lost OWASP flagship status and hasn't had active development for over a year now.
However, if you want to be able to detect multiple encoding attacks, there is no better alternative than using esapi and the ESAPI.encoder().canonicalize()
method, or one of the dozens of other validation methods that can be used.