我在某个网址[{3}}
中有一个xml文件我正在尝试获取xml
Client client = Client.create();
WebResource webResource = client.resource(" http://xy.com/test");
ClientResponse response = webResource.accept("application/xml").get(ClientResponse.class);
String textEntity=response.getEntity(String.class);
//textEntity=textEntity.replace("\n", "");
String xmlString= textEntity.toString();
JSONObject xmlinJsonObject = XML.toJSONObject(xmlString);
我遇到异常,我试图删除\ n字符,但问题仍然存在。
Exception in thread "main" org.json.JSONException: Unterminated string at 498551 [character 1 line 8394]
at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
at org.json.XMLTokener.nextMeta(XMLTokener.java:181)
at org.json.XML.parse(XML.java:176)
at org.json.XML.toJSONObject(XML.java:356)
at com.intuit.fds.fdp.document.ws.resource.XMLtoJson.main(XMLtoJson.java:47)