【发布时间】:2012-04-12 05:02:43
【问题描述】:
使用此代码未正确解析从 URL:“http://repository.sonatype.org/service/local/data_index?sha1=ba24d5de831911b684c92cd289ed5ff826271824”返回的 XML:
public static void main(String args[]){
try {
String urlString = "http://repository.sonatype.org/service/local/data_index?sha1=ba24d5de831911b684c92cd289ed5ff826271824";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new URL(urlString).openStream());
System.out.println("Doc is : "+doc);
}
catch(Exception e){
e.printStackTrace();
}
}
输出的 doc 值为 'Doc is : [#document: null]' 此外,没有抛出异常。 直接导航到 URL 似乎会生成有效的 XML。代码有问题吗?
【问题讨论】:
-
您似乎没有收到任何回复。
标签: java xml xml-parsing