的XML从URL返回:“http://repository.sonatype.org/service/local/data_index?sha1=ba24d5de831911b684c92cd289ed5ff826271824”不被使用此代码正确解析:XML从URL返回不正确解析
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是:[#document:null]'另外,没有任何异常被抛出。 直接导航到URL似乎产生有效的XML。代码有问题吗?
看来你没有得到任何回应。 – kosa 2012-03-28 15:12:37