Java tutorial
//package com.java2s; import java.util.Iterator; import java.util.LinkedHashMap; public class Main { public static String mapToXml(String s, LinkedHashMap linkedhashmap) { StringBuilder stringbuilder = new StringBuilder(); stringbuilder.append("<key>"); Object obj; for (Iterator iterator = linkedhashmap.entrySet().iterator(); iterator.hasNext(); stringbuilder .append((new StringBuilder("</")).append(obj).append(">").toString())) { java.util.Map.Entry entry = (java.util.Map.Entry) iterator.next(); obj = entry.getKey(); Object obj1 = entry.getValue(); if (obj == null) obj = "unknow"; if (obj1 == null) obj1 = "unknow"; stringbuilder.append((new StringBuilder("<")).append(obj).append(">").toString()); stringbuilder.append(obj1); } stringbuilder.append("</key>"); return stringbuilder.toString(); } }