org.xml.sax.SAXParseException: The reference to entity “T” must end with the ';' delimiter

前端 未结 9 1682
北海茫月
北海茫月 2020-12-29 07:35

I am trying to parse an XML file whcih contains some special characters like \"&\" using DOM parser. I am getting the saxparse exception \"the reference to entity must e

9条回答
  •  天命终不由人
    2020-12-29 07:52

    As a workaround, you can:

    1. Replace all the occurrences of & with & in the original input;
    2. Parse it;
    3. In your code that handles the result, handle the case where you now get escaped characters (e.g. < instead of <).

    Depending on the parser you're using, you can also try to find the class responsible for parsing and unescaping &-strings, and see if you can extend it/supply your own resolver. (What I'm saying is very vague, but the specifics depend on the tools you're using.)

提交回复
热议问题