List 导出XML格式

private void printXML(List<Map> list) throws BusinessExceptions{
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		sb.append("<result length=\""+list.size()+"\">");
		for (Map map : list) {
			Iterator<String> it = map.keySet().iterator();
			sb.append("<map length=\""+map.size()+"\"").append(">");
			while (it.hasNext()) {
				String key = (String) it.next();
				sb
				.append("<").append(key).append(">")
				.append(map.get(key))
				.append("</").append(key).append(">");
			}
			sb.append("</map>");
		}
		sb.append("</result>");
		System.out.println(sb.toString());
	}

你可能感兴趣的:(List 导出XML格式)