Here is a way to create xml dynamically in Java. We start with an arbitrary non-xml representation of the data and then make a DOM. We can then use LSSerializer to write to a file, or in the case below, to convert to a String. The source code is HERE.

import org.w3c.dom.*;
import org.w3c.dom.ls.*;

import java.io.*;

import java.util.*;

import javax.xml.parsers.*;


public class XmlGenerator {
    public static void main(String[] args) throws Exception {
        String xml = "ROOT(PARAMS,PARAM1,PARAM2,PARAM3)";
        Scanner s = new Scanner(xml);
        s.useDelimiter("[(),\\s]");

        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
                                             .newDocument();

        Node root = doc.createElement(s.next());
        doc.appendChild(root);

        Node sheet = doc.createElement(s.next());
        root.appendChild(sheet);

        while (s.hasNext()) {
            Node param = doc.createElement(s.next());
            sheet.appendChild(param);
        }

        System.out.println(XmlGenerator.getStringFromDoc(doc));
    }

    public static String getStringFromDoc(org.w3c.dom.Document doc) {
        DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
        LSSerializer lsSerializer = domImplementation.createLSSerializer();
        lsSerializer.getDomConfig()
                    .setParameter("format-pretty-print", Boolean.TRUE);

        return lsSerializer.writeToString(doc);
    }
}