예시 ) http://maps.googleapis.com/maps/api/geocode/xml?address=%EC%84%B8%EC%A2%85%EB%8C%80%EB%A1%9C%20110&language=ko&sensor=false
여기에잇는 xml을 좌표부분만 파싱을 해오려고합니다.
소스를
class SearchProcess1 extends AsyncTask<Void, String, String> {
private String status;
// 스레드 실제 작업
@Override
protected String doInBackground(Void... param) {
String adress ="";
try {
adress=URLEncoder.encode(pref.getString("pAdress", ""),"UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d(TAG, adress);
BasicNameValuePair svc = new BasicNameValuePair("svc",
"Depositinofo");
BasicNameValuePair padress = new BasicNameValuePair("padress", "http://maps.googleapis.com/maps/api/geocode/xml?address="+adress+"&language=ko&sensor=false");
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
paramList.add(svc);
paramList.add(padress);
status = clsServerConn.getResponse(URLmanager.getUrl()
+ "/AppSvc/Android/adress.aspx", paramList, 30);
return status;
}
// 스레드 작업 완료 후 호출
@Override
protected void onPostExecute(String status) {
Log.d(TAG, status);
try {
SAXBuilder builder = new SAXBuilder();
InputStream stream = new ByteArrayInputStream(
status.getBytes("UTF-8"));
Document doc = builder.build(stream);
Element xmlroot = doc.getRootElement();
editor.putString("lat" , xmlroot.getChild("lat")
.getValue().replace(" ", ""));
editor.putString("lng" , xmlroot.getChild("lng")
.getValue().replace(" ", ""));
editor.commit();
clsUtil.runIntent(NmapActivity.class);
finish();
} catch (JDOMException jdome) {
onPostExecute("ERR003");
} catch (IOException ioe) {
onPostExecute("ERR003");
} catch (NullPointerException npe) {
onPostExecute("ERR003");
}
}
}
});// onPostExecute
이렇게 작성을했습니다.
밑에는 에러코드입니다.
파싱하는 부분에서 잘못된거같은데...
어떤식으로 수정을해야될지 도저히 감이 안옵니다..
