我编写的Web应用程序读取XMl文件解析它并完成一些工作。
我不想使用本地文件,而是使用XML文件的URL(类似http://mydomain.com/daily-extract.xml)
这就是我的代码:
private String xmlFile = "D:\\default-user\\WINXP\\Desktop\\extract-jan10d.xml";
SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
// Parse the specified file and convert it to a JDOM document
document = builder.build(new File(xmlFile));
Element root = document.getRootElement();
如何从文件切换到互联网上的网址
答案 0 :(得分:0)
尝试替换此行:
document = builder.build(new File(xmlFile));
通过:
document = builder.build(新文件(新URI(“http://mydomain.com/daily-extract.xml”)));