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

后端 未结 4 1043
梦谈多话
梦谈多话 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:18

    Set the text content directly to the character you want, and the serializer will escape it for you if necessary:

    element.setTextContent("\u00A0");
    

提交回复
热议问题