Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String argumentTagToCmd(Element jobElement) { // NodeList nl = jobElement.getChildNodes(); // for(int i=0;i<nl.getLength();i++) // { // System.out.println(nl.item(i).getTextContent()); // } // System.exit(1); // Node n = jobElement.getElementsByTagName("argument").item(0); String taskName = jobElement.getAttribute("name"); // String nodeString = nodeToString(n); // nodeString = nodeString.replace("<"+n.getNodeName()+">", ""); // nodeString = nodeString.replace("</"+n.getNodeName()+">", ""); // nodeString = nodeString.trim(); // String[] lines = nodeString.split("\n"); StringBuilder cmd = new StringBuilder(taskName).append(";"); NodeList argList = jobElement.getElementsByTagName("argument").item(0).getChildNodes(); for (int i = 0; i < argList.getLength(); i++) { Node c = argList.item(i); String cStr; if (c.getNodeName().equals("file")) { Element ec = (Element) c; cStr = (ec.getAttribute("name")).trim(); if (!cStr.isEmpty()) { cmd.append(cStr).append(";"); } } else { cStr = (c.getTextContent().trim()); String[] cStrs = cStr.split("\\s+"); for (String cs : cStrs) { cs = cs.trim(); if (!cs.isEmpty()) { cmd.append(cs).append(";"); } } } } cmd.replace(cmd.length() - 1, cmd.length(), ""); return cmd.toString(); } }