我有一个 XML 响应(根据编码属性应该是 UTF-8),其中包含一个字符“\uffff\u0551”作为元素,xmlParseMemory()
结果带有错误 XML-Verarbeitungsfehler: nicht wohlgeformt
[格式不正确].
我可以设置 parserChain,以便库将跳过这些字符并继续使用结果文档进行解析吗?
我确实从 xmlsoft.org 阅读了一些(不是全部)手册页,但没有找到任何内容。
最佳答案
没有。 FFFF 不是 valid Unicode character ,无效字符是 fatal error ,XML 规范声明 fatal errors are unrecoverable :
Once a fatal error is detected, however, the processor must not continue normal processing (i.e., it must not continue to pass character data and information about the document's logical structure to the application in the normal way).
如果要解析此文档,则需要在将其交给 XML 解析器之前清除无效字符。
关于读取丑字后继续解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32499191/