Java tutorial
//package com.java2s; import java.util.SortedMap; public class Main { public static String toXml(SortedMap<String, String> params) { StringBuilder sb = new StringBuilder(); sb.append("<xml>"); for (SortedMap.Entry<String, String> entry : params.entrySet()) { sb.append("<").append(entry.getKey()).append(">"); sb.append(entry.getValue()); sb.append("</").append(entry.getKey()).append(">"); } sb.append("</xml>"); return sb.toString(); } public static String toXml(SortedMap<String, String> params, String sign) { StringBuilder sb = new StringBuilder(); sb.append("<xml>"); for (SortedMap.Entry<String, String> entry : params.entrySet()) { sb.append("<").append(entry.getKey()).append(">"); sb.append(entry.getValue()); sb.append("</").append(entry.getKey()).append(">"); } sb.append("<").append("sign").append(">"); sb.append(sign); sb.append("</").append("sign").append(">"); sb.append("</xml>"); return sb.toString(); } }