Java tutorial
//package com.java2s; import java.util.Map; import java.util.Map.Entry; public class Main { public static String fromat(Map<String, String> map, String relname, String crid) { StringBuffer xml = new StringBuffer(); xml.append("<root>"); for (Entry<String, String> en : map.entrySet()) { xml.append("<attr n='" + en.getKey() + "' d='text'><![CDATA[" + en.getValue() + "]]></attr>"); } xml.append("<rel n='" + relname + "' d='from'><![CDATA[" + crid + "]]></rel>"); xml.append("</root>"); return xml.toString(); } }