SAX parser: Ignoring special characters

前端 未结 4 686
说谎
说谎 2020-12-07 01:41

I\'m using Xerces to parse my XML document. The issue is that XML escaped characters like   appear in characters() method as non-escap

4条回答
  •  遥遥无期
    2020-12-07 02:14

    There is one more may: escapeXml method of org.apache.commons.lang.StringEscapeUtils class.

    Try this code in your characters(char[] ch, int start, int length) method:

    String data=new String(ch, start, length);
    String escapedData=org.apache.commons.lang.StringEscapeUtils.escapeXml(data);
    

    You may download the jar here.

提交回复
热议问题