Skip to content

XML 转换 EDIFACT 时出现报错提示 "Unexpected character ' ' (code 32)"

问题现象

XML 转换 EDIFACT 时出现以下报错:

The edi xml file is invalid. Unexpected character ' ' (code 32); expected a semi-colon after the reference for entity 'Z'

错误截图

问题根因

解析出的 XML 中包含特殊字符(如 < > & " '),直接写在待解析的 XML 中会导致解析失败。

根因分析

解决方案

在解析可能包含此类字符的字段时,使用 XML_ENCODE() 方法进行转义。

解决示例

提示:XML 特殊字符需正确转义后再进行解析,否则会触发解析器错误。