我有一个https://connectionsww.demos.ibm.com/dm/atom/library/ECD/document/AA/media/install.log.qkr
链接,点击此链接后,会有一个窗口询问我是否要打开它或保存它。
无论哪种方式,它的内容都是XML,它们是
<link id="2b46808042971cf480ad8db51e04c09f" formatVersion="1.0"><server url="http://quickr85.test.com:10040"/><library id="044e6100428e6550809e8db51e04c09f" path=""/><document id="2b46808042971cf480ad8db51e04c09f" path=""/><creator dn="" name="" email=""/></link>
响应的Content-Disposition是“附件”,Content-Type是XML。
我尝试使用DOM直接解析此URL:
URL qkrFileUrl = new URL(requestURL);
// URLConnection urlConnection = new URLConnection();
URLConnection urlConnection = qkrFileUrl.openConnection();
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(urlConnection.getInputStream()));
String line = null;
String XMLFile = new String();
while(bufferedReader.readLine()!=null)
{
line = bufferedReader.readLine();
LOGGER.debug("Line is "+line);
XMLFile += line;
}
但XMLFile的结果是一堆乱码:
Error 500: java.net.MalformedURLException: no protocol: <html lang="en-us" dir="ltr"> <meta http-equiv="X-LConn-Login" content="true"> <meta http-equiv="pragma" content="no-cache">if (self != top) { try { // per Same Origin Policy, try to get top location attributes, if (self.location.hostname != top.location.hostname) { top.location=self.location; }catch(e){ document.getElementsByTagName('body')[0].style.display = 'none'; }} __iContainer_skip_init__ = true;<!--[if IE 6]><script>document.getElementsByTagName("html")[0].className+=" lotusui_ie lotusui_ie6";</script><![endif]--><!--[if IE 8]><script>document.getElementsByTagName("html")[0].className+=" lotusui_ie8";</script><![endif]--><link rel="stylesheet" type="text/css" id="lotusBaseStylesheet" href="https://connectionsww.demos.ibm.com/connections/resources/web/_style?include=com.ibm.lconn.core.styles.oneui3/base/package3.css&etag=20140502.131757" appName="webresources" base="https://connectionsww.demos.ibm.com/connections/resources/web/" query="?version=oneui3&rtl=false&etag=20140502.131757" theme="default" defaultTheme="default" oneui="3"></link><link rel="stylesheet" type="text/css" id="lotusThemeStylesheet" href="https://connectionsww.demos.ibm.com/connections/resources/web/_lconntheme/default.css?version=oneui3&rtl=false&etag=20140502.131757"></link><div class="lotusui30_layout"> <div class="lotusLoginContent"> <p>Find out more <a href="http://www-306.ibm.com/software/lotus/products/connections/" aria-label="More about Connections at IBM.com">at ibm.com</a></p> <p><a href="https://connectionsww.demos.ibm.com/help/topic/com.ibm.lotus.connections.common.help/euframe.html">Try the IBM Connections product documentation</a></p> <form class="lotusForm2 lotusLoginForm" role="main" method="post" action="/connections/resources/j_security_check"> <h1 class="lotusHeading">Welcome to IBM Connections</h1> <input id="service.name" type="hidden" name="service.name" value="ecm_files"> <input id="fragment" type="hidden" name="fragment" value=""> <label for="username">User name:</label> </p> <label for="password">Password:</label> </p> <span class="lotusRight" aria-hidden="true"><img role="presentation" src="https://connectionsww.demos.ibm.com/connections/resources/web/com.ibm.lconn.core.styles.oneui3/images/blank.gif?etag=20140502.131757" alt="IBM" class="lotusIBMLogo"><span class="lotusAltText">IBM</span></span> </form> </div> <script type="text/javascript"> serviceName: "webresources", contextRootEnabler: "/connections/resources",};var baseHost = "connectionsww.demos.ibm.com";var needProxy = (baseHost != window.location.host || baseProtocol+":" != window.location.protocol); isDebug: false, locale: "en-us", blankGif: "https://connectionsww.demos.ibm.com/connections/resources/web/com.ibm.lconn.core.styles.oneui3/images/blank.gif?etag=20140502.131757", proxy: "/connections/resources/ajaxProxy",};<script type="text/javascript"> base: "https://connectionsww.demos.ibm.com/connections/resources", params: "etag=20140502.131757&lang=en&country=US"CKEDITOR_BASEPATH = window.CKEDITOR_BASEPATH || "https://connectionsww.demos.ibm.com/connections/resources/web/com.ibm.oneui.ckeditor/editor/"; <!-- local script service: /web/_xdloader2?etag=20140502.131757&lang=en&country=US&_proxyURL=https%3A%2F%2Fconnectionsww.demos.ibm.com%2Fconnections%2Fresources&include=lconn.core.bundle_common.js%7E&html=true --><script type="text/javascript" src="https://connectionsww.demos.ibm.com/connections/resources/web/_js?include=lconn.core.bundle_common.js~&exclude=dojo.dojo.js~&etag=20140502.131757&lang=en&country=us"></script> dojo.addOnLoad(function() { if (fragment) { fragment = fragment.substring(1); input.value = input.value || fragment; try { if (dojo.indexOf([_u, _p], document.activeElement) === -1) } catch (e) {} var redirect = findRedirectInFragment("\/dm\/atom\/library\/ECD7B321-7729-430F-9F5C-9279D83EF13E;D826C8CD-2B72-4546-82AF-A3D23377C061\/document\/%7BF2CA2079-F96F-4B3C-8B87-5CB0B616D743%7D\/media\/install.log.qkr","",""); function findRedirectInFragment(redirect, base, query) { if (hash) { if (hash.length > 0) { hash = hash.substring(1); if (queryMarker != -1) { hash = hash.substring(0,queryMarker); if (hash.charAt(0) == "/" && base.charAt(base.length-1) == "/") base += hash; } return redirect; </script></html>null
有人可以告诉我如何解析XML文件?谢谢!