问题描述
用xom 转换 json 为xml时报异常nu.xom.IllegalCharacterDataException: 0x12 is not allowed in 异常信息如下nu.xom.IllegalCharacterDataException: 0x12 is not allowed in XML contentat nu.xom.Verifier.throwIllegalCharacterDataException(Verifier.java:154)at nu.xom.Verifier.checkPCDATA(Verifier.java:205)at nu.xom.Text._setValue(Text.java:126)at nu.xom.Text.<init>(Text.java:62)at nu.xom.Element.appendChild(Element.java:1069)at net.sf.json.xml.XMLSerializer.processJSONValue(XMLSerializer.java:993)at net.sf.json.xml.XMLSerializer.processJSONObject(XMLSerializer.java:953)at net.sf.json.xml.XMLSerializer.processJSONValue(XMLSerializer.java:1003)at net.sf.json.xml.XMLSerializer.processJSONObject(XMLSerializer.java:953)at net.sf.json.xml.XMLSerializer.processJSONValue(XMLSerializer.java:1003)at net.sf.json.xml.XMLSerializer.processJSONObject(XMLSerializer.java:953)at net.sf.json.xml.XMLSerializer.write(XMLSerializer.java:593)at com.njjh.util.Util.getXMLFromJSON(Util.java:793)at com.njjh.servlet.Information.service(Information.java:53)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Thread.java:619)为什么呢,大神!!!!
解决方案
表明显你用到了非法的字符,0x12 ,你需要用转义字符来做转义。