Unable to parse value containing special character? Using sax parser

前端 未结 4 1318
逝去的感伤
逝去的感伤 2021-01-13 15:48

I am new to parsing field. I\'m trying to write a parser code but unable to get the value with respect to a particular tag that value contains ampersand(&).

4条回答
  •  醉话见心
    2021-01-13 16:21

    You must replace your special characters with the characters that are accepted for an XML file. In your case & should be replaced by &

    @Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
        content = String.copyValueOf(ch, start, length).trim();
        content = content.replace("&", "&")
    }
    

提交回复
热议问题