Java tutorial
//package com.java2s; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.SortedMap; public class Main { public static String createXml(SortedMap<String, String> sm, String sign) { StringBuilder sb = new StringBuilder(); sb.append("<xml>"); Set<Map.Entry<String, String>> set = sm.entrySet(); for (Iterator<Map.Entry<String, String>> it = set.iterator(); it.hasNext();) { Map.Entry<String, String> entry = it.next(); sb.append("<").append(entry.getKey()).append(">"); sb.append(entry.getValue()); sb.append("</").append(entry.getKey()).append(">"); } sb.append("<sign>").append(sign).append("</sign>"); sb.append("</xml>"); return sb.toString(); } }