如何根据邮政编码获取最近的剧院列表?

时间:2011-05-13 01:28:08

标签: java api

我需要根据用户的邮政编码输入找到附近的影院列表,我有一个api,如果我们传递了zipcode但是我不确定如何使用这个api,这是我第一次尝试获取此信息来自api的数据,我不熟悉atompoxast首字母缩略词。

提供影院信息的API位于http://gateway.moviefone.com/,任何指导建议都会非常感谢您开始使用此api并了解如何使用api。

1 个答案:

答案 0 :(得分: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();