node_id 节点编号 up_node 父节点编号node_value 节点编号值
public String createxml(HashMap<String,String> inmap,List<Map<String, String>> bodylistmap) {
Map<String, String> map = new HashMap<String, String>();
map = bodylistmap.get(0);
String message_id = inmap.get("message_id");
String message_code = inmap.get("message_code");
xmlnodes.append("<?xml version=\"1.0\" encoding=\"").append(message_code).append("\"?>");
try {
getMsg("0","",message_id,map);
} catch (Exception e) {
e.printStackTrace();
}
return xmlnodes.toString();
}
public void getMsg(String up_node,String node_value,String message_id,Map<String,String> map) throws Exception {
MessageTreeBo messageTreeBo = (MessageTreeBo) SourceTemplate.getSpringContextInstance().getBean("messageTreeBo");
MessageTree messageTress = null;
List<MessageTree> messageTrees = messageTreeBo.getMsgByParent(up_node,message_id);
int len = messageTrees.size();
if(len == 0){
xmlnodes.append(getNodeValue(node_value,map));
}else{
for(int i = 0; i < len;i++ ){
messageTress = messageTrees.get(i);
xmlnodes.append("<").append(messageTress.getNode_key()).append(">");
getMsg(messageTress.getNode_id(),messageTress.getNode_value(),message_id,map);
xmlnodes.append("</").append(messageTress.getNode_key()).append(">");
}
}
}
public String getNodeValue(String node_value,Map<String,String> map){
if(node_value != null && node_value!="null"){
if(node_value.startsWith("$")){
node_value=(String) map.get(node_value.substring(1));
return node_value;
} else {
return node_value;
}
}else {
return "";
}
}