public void selectLatLng() throws Exception {
// 주소, 위도, 경도
CommonMapSet modelSet = (CommonMapSet) this.getModelSet(CommonMapSet.class, CommonMap.class);
// ModelSet인터페이스를 IXyncDataSet에 바인딩한다.
modelSet.bind(this);
String strKey = super.getParameterString("KEY");
String strSetAddr = super.getParameterString("SET_ADDR");
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build("http://map.naver.com/api/geocode.php?key=" + strKey + "&encoding=utf-8&coord=latlng&query=" + strSetAddr.replace(" ", ""));
Element root = doc.getRootElement();
List<Element> elements = root.getChildren();
HashMap model = new HashMap();
for (Element element:elements) {
if (element.getName().equals("item")) {
List<Element> items = element.getChildren();
for (Element item:items) {
if (item.getName().equals("point")) {
List<Element> points = item.getChildren();
for (Element point:points) {
if (point.getName().equals("y")) {
model.put("LAT", point.getText()); // 위도
}
if (point.getName().equals("x")) {
model.put("LNG", point.getText()); // 경도
}
}
}
if (item.getName().equals("address")) {
model.put("ADDRESS", item.getText()); // 주소
}
}
modelSet.appendRow((Map) model);
}
}
modelSet.flush();
}