简要说明:
我有一个 xml 文件的 url 保存内容。我想解析这个文件以使用下面的代码:
private String GetFileUrl() {
return "https://dl-web.dropbox.com/get/My%20Projects/Xml%20Files/Vk%20Iu%20Quilling/KeyList.xml?w=AAD6Cf_YdXRg5tyY4cquyiXBZ8XuQUsIbsMGVoIfkgPcpg";
}
private NodeList SetUpXmlParserUrl() {
try {
URL xmlFile = new URL(fileUrl);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
InputStream inputStream = xmlFile.openStream();
Document doc = dBuilder.parse(inputStream);
//Get Node need to be parse.
NodeList productNodeList = doc.getElementsByTagName("Item");
return productNodeList;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
当此代码运行时,我收到此错误:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://dl-web.dropbox.com/get/My%20Projects/Xml%20Files/Vk%20Iu%20Quilling/KeyList.xml?w=AAD6Cf_YdXRg5tyY4cquyiXBZ8XuQUsIbsMGVoIfkgPcpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
任何人都可以帮忙请..