的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