Вы, вероятно, можете сделать это в следующих шагах:
1> Подготовьте URI запроса, где присутствует xml.
prepareRequestUrl();
2> Получить ответ с веб-сервера:
/**
* fetch the response for the request url
* @param request url string
* @return InputStream
*/
public InputStream getResponse(String reqUrl) throws AppException {
URL url = null;
URLConnection connection = null;
HttpURLConnection httpConnection = null;
int reponseCode = 0;
InputStream inputStream = null;
try {
url = new URL(reqUrl);
connection = url.openConnection();
httpConnection = (HttpURLConnection) connection;
reponseCode = httpConnection.getResponseCode();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
if (reponseCode == HttpURLConnection.HTTP_OK) {
try {
inputStream = httpConnection.getInputStream();
} catch (IOException e) {
}
}
else {
throw new AppException(AppConstants.HTTP_RESPONSE_FAILURE);
}
return inputStream;
}
3> Разбор входного потока xml, полученного с сервера:
inputStream = super.getResponse(requestUrl);
result= xmlParser.parseList(inputStream);
4> Показать соответствующий результат в виде списка.
Примечание. Всегда рекомендуется использовать асинхронную задачу для выполнения любой сетевой операции. Здесь в этом случае вызывается we-сервер.
Надеюсь, это поможет!