Javascript 如何从URL解析XML附件文件?

Javascript 如何从URL解析XML附件文件?,javascript,xml,xml-parsing,dojo,httpurlconnection,Javascript,Xml,Xml Parsing,Dojo,Httpurlconnection,我有一个链接是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.co

我有一个链接是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>
但是XMLFile的结果是一堆JavaScript代码:

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文件吗?谢谢大家!

实际上,您无法在该位置获取XML!检查URL。。。它包含一个dmRedirect,因此您可以猜测,某些JavaScript或HTTP响应头会将您发送到另一个URL。使用curl检查是否是这种情况,然后使用它one@stwissel抱歉,应该是dm…dmRedirect是我编写的用于解析XML的servlet。我正在使用一些mod_重写来转换这个原始的请求URL。好的,我明白了。第一步需要确定您实际使用正确的凭据调用了正确的URL。Curl是你的朋友。此外,使用http客户端比使用URLConnection更容易。看起来你给我们的不是重定向就是登录,而不是实际的文件
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