How to disable/avoid Ampersand-Escaping in Java-XML?

后端 未结 4 1070
梦谈多话
梦谈多话 2021-01-05 10:50

I want to create a XML where blanks are replaced by  . But the Java-Transformer escapes the Ampersand, so that the output is  

4条回答
  •  一向
    一向 (楼主)
    2021-01-05 11:24

    As addon to forty-two's answer:

    If, like me, you're trying the code in a non-patched Eclipse IDE, you're likely to see some weird A's appearing instead of the non-breaking space. This is because of the encoding of the console in Eclipse not matching Unicode (UTF-8).

    Adding -Dfile.encoding=UTF-8 to your eclipse.ini should solve this.

    Cheers, Wim

提交回复
热议问题