我们有一个JAVA应用程序,可以从SAP中提取数据,进行解析并将其呈现给用户. 使用JCO连接器提取数据.
We have a JAVA application that pulls the data from SAP, parses it and renders to the users. The data is pulled using JCO connector.
最近我们被抛出了一个异常:
Recently we were thrown an exception:
org.xml.sax.SAXParseException: Character reference "�" is an invalid XML character.因此,我们计划编写一个新的间接级别,其中在解析XML之前,将替换所有特殊/非法字符.
So, we are planning to write a new level of indirection where ALL special/illegal characters are replaced BEFORE parsing the XML.
我的问题是:
谢谢.
推荐答案听起来像是他们转义中的错误.根据上下文的不同,您最好只编写自己的使用真实XML库的XMLWriter类版本,而不是像SAP开发人员那样尝试编写自己的XML实用程序.
It sounds like a bug in their escaping. Depending on context you might be best off just writing your own version of their XMLWriter class that uses a real XML library rather than trying to write your own XML utilities like the SAP developers did.
或者,查看字符代码�,也许可以用空字符串替换掉所有字符:
Alternatively, looking at the character code, �, you might be able to get away with a replace all on it with the empty string:
String goodXml = badXml.replaceAll("�", "");更多推荐
使用SAX进行XML解析
发布评论