public static Map<String, Object> formatResponseAsMap(InputStream stream) throws Exception {
		Map<String, Object> mapResponse = new LinkedHashMap<String, Object>();
		try {
			DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = docFactory.newDocumentBuilder();
			Document document = builder.parse(stream);
			document.getDocumentElement().normalize();
			NodeList response = document.getElementsByTagName("response");
			for(int i=0; i< response.getLength(); i++){
				//response
				Node responseItem = response.item(i);
				//responseID, result
				NodeList allResponseChild = responseItem.getChildNodes();
				for(int j=0; j< allResponseChild.getLength(); j++){
					//responseID, result
					Node eachResponseChild = allResponseChild.item(j);
					if(eachResponseChild.getNodeName().equals("responseID")){
						mapResponse.put("responseID", eachResponseChild.getTextContent());
						continue;
					}
					NodeList resultItem = eachResponseChild.getChildNodes();
					Map<String,Object> mapResult = new LinkedHashMap<String,Object>();
					for(int k=0; k < resultItem.getLength(); k++){
						//resultID, item
						Node eachResultItem = resultItem.item(k);
						if(eachResultItem.getNodeName().equals("resultID")){
							mapResult.put("resultID", eachResultItem.getTextContent());
							continue;
						}
						//item, key/value
						NodeList nodeItemAtResult = eachResultItem.getChildNodes();
						String key = null;
						String value = null;
						for(int c = 0; c < nodeItemAtResult.getLength(); c++){
							//key, value
							Node eachItemAtResult = nodeItemAtResult.item(c);
							if(eachItemAtResult.getNodeName().equals("key")){
								key = eachItemAtResult.getTextContent();
							}else{
								value = eachItemAtResult.getTextContent();
							}
						}
						mapResult.put(key, value);
					}
					mapResponse.put(String.valueOf(mapResult.get("resultID")), mapResult);
				}
			}
		return mapResponse;
		} catch (Exception e) {
			throw new Exception("Error formatting response", e);
		}
	}