org.xml.sax.SAXParseException:attribute" id"的值与元素类型相关联"员工"不得包含'<'字符。在

时间:2015-07-03 08:40:36

标签: java xml

当我尝试阅读XML解析时,我遇到了问题,我输入XML包含一些特殊字符,例如&,<,>和""。 使用SAXParse api解析XML时,在Excpetions下面进行解析。

org.xml.sax.SAXParseException: The value of attribute "id" associated with an element type "Employee" must not contain the '<' character. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

请在XML解析发生之前告诉我如何替换特殊字符。 如果有任何机构有一段代码,请分享。

非常有帮助! -Vishwanath

1 个答案:

答案 0 :(得分:0)

您需要转义以下字符

"   &quot;
'   &apos;
<   &lt;
>   &gt;
&   &amp;