From: jack <lil...@16...> - 2016-06-22 08:56:38
|
Hi asashour This is not a cross domain problem,the warning: Content is not allowed in prolog is the key I solved the problem by the following code new WebConnectionWrapper(wc) { public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); if(request.getUrl().toExternalForm().contains("goalBf3.xml")){ System.out.println(response.getContentAsString("UTF-8")); String content = response.getContentAsString("UTF-8"); if(null != content && !"".equals(content)){ if(content.indexOf("<") != -1 && content.lastIndexOf(">") != -1 && content.lastIndexOf(">") > content.indexOf("<")) content = content.substring(content.indexOf("<"), content.lastIndexOf(">") + 1); } WebResponseData data = new WebResponseData(content.getBytes("UTF-8"), response.getStatusCode(), response.getStatusMessage(), response.getResponseHeaders()); response = new WebResponse(data, request, response.getLoadTime()); } return response; } } -- View this message in context: http://htmlunit.10904.n7.nabble.com/How-to-solve-the-cross-domain-problem-caused-by-the-error-tp39637p39641.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |