Document dws;
try {
dws = XmlFactory.getResource("/com/newzhongway/service/test.xml");
ExtDocument ext= new ExtDocument(dws);
String rexml = XmlFactory.getXmlStr(dws);
String jsonStr = Xml2JsonUtil.xml2JSON(rexml);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myclipse在控制台
中出错org.jdom.input.JDOMParseException: Error on line 0: The encoding "GBK" is not supported.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
at com.zhongway.pub.handler.Xml2JsonUtil.xml2JSON(Xml2JsonUtil.java:30)
at com.zhongway.pub.handler.Xml2JsonUtil.main(Xml2JsonUtil.java:214)
Caused by: org.xml.sax.SAXParseException: The encoding "GBK" is not supported.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1196)
at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:541)
at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:312)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1080)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
... 3 more
我的xml文件是
<?xml version='1.0' encoding='gb2312'?>
<interfacemsg>
<query>
<sheetNo>2015080700001</sheetNo>
<DEALER>KEDA</DEALER>
<PROV>sn_eoms</PROV>
</query>
<result>
<sheetDetailInfo>
<BasicInfo>
<WSID>2015080700001</WSID>
<WSTYPECODE>移动专业故障</WSTYPECODE>
<WSINFOHINT>移动网:CDMA网;故障对象:测试</WSINFOHINT>
<BEGINTIME>2015-08-07 08:45:01</BEGINTIME>
<ENDTIME></ENDTIME>
<STATUS>受理派单</STATUS>
<URGEDEGREE>一般</URGEDEGREE>
<PASTTIME>4734</PASTTIME>
</BasicInfo>
<handleInfoList>
<handleInfo>
<TASKNAME>申告工单</TASKNAME>
<TASKCREATETIME>2015-08-07 08:45:01</TASKCREATETIME>
<HANDLEPERSON>KEDA</HANDLEPERSON>
<TASKRECEIVETIME></TASKRECEIVETIME>
<HANDLETIME>2015-08-07 08:45:02</HANDLETIME>
<HANDLEDETAIL></HANDLEDETAIL>
</handleInfo>
<handleInfo>
<TASKNAME>受理派单</TASKNAME>
<TASKCREATETIME>2015-08-07 08:45:01</TASKCREATETIME>
<HANDLEPERSON></HANDLEPERSON>
<TASKRECEIVETIME></TASKRECEIVETIME>
<HANDLETIME></HANDLETIME>
<HANDLEDETAIL></HANDLEDETAIL>
</handleInfo>
</handleInfoList>
<applyInfo>
<CUSTTYPE></CUSTTYPE>
<APPLYER>KEDA</APPLYER>
<APPLYTIME>2015-08-07 08:45:00</APPLYTIME>
<APPLYUNIT>科大恒星</APPLYUNIT>
<TROUBLEOBJ>测试</TROUBLEOBJ>
<NETWORK>CDMA网</NETWORK>
<APPLYCLASS>国内漫游</APPLYCLASS>
<APPLYCLASSSMALL>语音业务</APPLYCLASSSMALL>
<TROUBLEDESCR>测试</TROUBLEDESCR>
<CCFXHJDCL>初步分析处理</CCFXHJDCL>
<IFINFLBUSI>否</IFINFLBUSI>
<HAPPENTIME>2015-08-07 03:00:00</HAPPENTIME>
<IFFIRSTFOUND>是</IFFIRSTFOUND>
<TROUBLESOURCE>其他</TROUBLESOURCE>
<TIMELIMIT></TIMELIMIT>
<CUSTLEVEL></CUSTLEVEL>
<GECUSTCLASS></GECUSTCLASS>
<CUSTINDUS></CUSTINDUS>
<CUSTSL></CUSTSL>
<CUSTLOCAL></CUSTLOCAL>
<OTHERCUSTINFO></OTHERCUSTINFO>
<ADDITIONALREMARK></ADDITIONALREMARK>
<ROAMINGTYPE></ROAMINGTYPE>
<ROAMINGCOUNTRY></ROAMINGCOUNTRY>
<IMSI></IMSI>
<CUSTNAME></CUSTNAME>
</applyInfo>
<dispatchInfoList/>
<dealInfoList/>
<hangupInfoList/>
<callCenterInfoList/>
<attachInfoList/>
<OPList/>
</sheetDetailInfo>
<returnVal>
<RETURN_CODE>0</RETURN_CODE>
<RETURN_DESC>完成</RETURN_DESC>
</returnVal>
</result>
</interfacemsg>
但为什么我有这个错误? 有人可以帮我解决这段代码的错误。 我在网上搜索了很长时间。但没用。请帮助或尝试提供一些如何实现此目的的想法