public Map getRequestXML(String strXML){
/*
String strXML = "<requestList>" +
"<requestMessage><resultCode>p01</resultCode><resultMessage>1111</resultMessage><prodOrderId></prodOrderId><kenanOrderId></kenanOrderId><serviceType></serviceType><DNorKmID></DNorKmID><subscribeNo></subscribeNo><accountNo></accountNo></requestMessage>"
+
"<requestMessage><resultCode>p01</resultCode><resultMessage>1111</resultMessage><prodOrderId></prodOrderId><kenanOrderId></kenanOrderId><serviceType></serviceType><DNorKmID></DNorKmID><subscribeNo></subscribeNo><accountNo></accountNo></requestMessage>"
+
"</requestList>";
*/
Map map = new HashMap();
StringReader read = new StringReader(strXML);
InputSource source = new InputSource(read);
SAXReader sb = new SAXReader();
try {
Document doc =sb.read(source);
Element root = doc.getRootElement();
List messageList = root.elements("requestMessage");
if(messageList.size()==2){
List list = new ArrayList();
for(int i=0;i<messageList.size();i++){
Element element = (Element)messageList.get(i);
System.out.println(element.asXML());
Map map1 = new HashMap();
map1.put("resultCode", this.getValueFromXML(element, "resultCode"));
map1.put("resultMessage", this.getValueFromXML(element, "resultMessage"));
map1.put("prodOrderId", this.getValueFromXML(element, "prodOrderId"));
map1.put("kenanOrderId", this.getValueFromXML(element, "kenanOrderId"));
map1.put("serviceType", this.getValueFromXML(element, "serviceType"));
map1.put("DNorKmID", this.getValueFromXML(element, "DNorKmID"));
map1.put("subscribeNo", this.getValueFromXML(element, "subscribeNo"));
map1.put("accountNo", this.getValueFromXML(element, "accountNo"));
list.add(map1);
}
System.out.println(list);
map.put("returnNumber", "2");
map.put("returnValue", list);
map.put("returnType", "String");
}else if(messageList.size()==1){
Element element = (Element)messageList.get(0);
List list = new ArrayList();
Map map1 = new HashMap();
map1.put("resultCode", this.getValueFromXML(element, "resultCode"));
map1.put("resultMessage", this.getValueFromXML(element, "resultMessage"));
map1.put("prodOrderId", this.getValueFromXML(element, "prodOrderId"));
map1.put("kenanOrderId", this.getValueFromXML(element, "kenanOrderId"));
map1.put("serviceType", this.getValueFromXML(element, "serviceType"));
map1.put("DNorKmID", this.getValueFromXML(element, "DNorKmID"));
map1.put("subscribeNo", this.getValueFromXML(element, "subscribeNo"));
map1.put("accountNo", this.getValueFromXML(element, "accountNo"));
list.add(map1);
System.out.println(list);
map.put("returnNumber", "1");
map.put("returnValue", list);
map.put("returnType", "List");
}else{
map.put("returnNumber", "0");
map.put("returnValue", "");
map.put("returnType", "String");
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}