Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static void appendCollection(Node node, Collection c, String tag) { appendCollection(node, c.toArray(), tag); } public static void appendCollection(Node node, Object[] o, String tag) { Element child = node.getOwnerDocument().createElement(tag); for (int i = 0; i < o.length; i++) { child.setAttribute("element_" + i, (String) o[i]); } node.appendChild(child); } }