2011-05-13 31 views
3

我需要根據用戶的郵政編碼輸入找到附近的劇院列表,如果我們通過郵政編碼,但是我不確定如何使用這個api,我有一個api提供這些信息,這是我第一次嘗試獲取數據來自API並且我不熟悉​​,poxast縮寫詞。如何根據郵政編碼獲得最近的影院列表?

提供劇院信息的API位於http://gateway.moviefone.com/,任何指導建議都將非常感謝您開始使用此API並瞭解如何使用API​​。

+0

http://gateway.movi​​efone.com/movies/rss/closesttheaters.xml?zip=YOURZIPCODE,然後解析內容?用戶輸入zip你填寫url然後解析內容。每個電影院都包含項目標籤,所以你可以把它解析爲一個xml文檔,而不是熟悉Java。但是...... – 2011-05-13 01:40:11

+0

@Andrew:什麼是'ast'或'pox'? – Rachel 2011-05-13 01:43:05

+0

POX是普通的舊xml – 2011-05-13 01:50:20

回答

2

有涉及幾個步驟,這裏的一些僞代碼,以幫助您開始:

String zip = "..."; 
String url = "http://gateway.moviefone.com/movies/pox/closesttheaters.xml?zip=" + zip; 

// read and parse the xml 
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
DocumentBuilder builder = factory.newDocumentBuilder(); 
Document document = builder.parse(url); 

//get elements you need 
NodeList list = document.getElementsByTagName("closestTheatersUrl"); 
String urlForTheater = list.item(0).getNodeValue(); 
相關問題