Java tutorial
//package com.java2s; import java.util.Map.Entry; import java.util.SortedMap; public class Main { public static String createXML(SortedMap<String, Object> parameters) { StringBuilder buffer = new StringBuilder(); buffer.append("<xml>"); for (Entry<String, Object> entry : parameters.entrySet()) { String k = (String) entry.getKey(); String v = String.valueOf(entry.getValue()); if (!"null".equals(v) && !"".equals(v)) { buffer.append("<" + k + ">" + v + "</" + k + ">" + "\r\n"); } } buffer.append("</xml>"); return buffer.toString(); } }