解析树形结构,拼XML

node_id 节点编号 up_node 父节点编号node_value 节点编号值
public String createxml(HashMap inmap,List bodylistmap) {
Map map = new HashMap();
map = bodylistmap.get(0);
String message_id = inmap.get("message_id");
String message_code = inmap.get("message_code");
xmlnodes.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 map) throws Exception {
MessageTreeBo messageTreeBo = (MessageTreeBo) SourceTemplate.getSpringContextInstance().getBean("messageTreeBo");
MessageTree messageTress = null;
List 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("");
}
}
}
public String getNodeValue(String node_value,Map map){
if(node_value != null && node_value!="null"){
if(node_value.startsWith("$")){
node_value=https://www.it610.com/article/(String) map.get(node_value.substring(1));
return node_value;
} else {
return node_value;
}
}else {
return "";
}

}
【解析树形结构,拼XML】转载于:https://www.cnblogs.com/wzh0125/p/4462764.html

    推荐阅读