2012-02-11 46 views
0

創建一個DOM文檔的URL:http://www.evemarketeer.com/api/orders/10000043/30119/xml從網址

我想這

 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
     DocumentBuilder db = dbf.newDocumentBuilder(); 
     Document doc = db.parse(url.openStream()); 

但不工作,任何人有任何想法,以創建一個簡單的方法的文檔?

THX

+2

什麼意思它不工作?任何錯誤? – kosa 2012-02-11 00:32:03

+0

沒有錯誤,但var doc爲空。 – Falydoor 2012-02-11 00:36:25

+0

你確定流回傳嗎? – kosa 2012-02-11 00:37:24

回答

3

這對我的作品(返回28 「行」 元素)

URL url = new URL("http://www.evemarketeer.com/api/orders/10000043/30119/xml"); 
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
DocumentBuilder db = dbf.newDocumentBuilder(); 
Document doc = db.parse(url.openStream()); 
NodeList nodes = doc.getElementsByTagName("row"); 
System.out.println(nodes.getLength()) + " nodes found";