Example usage for org.w3c.dom Document appendChild

List of usage examples for org.w3c.dom Document appendChild

Introduction

In this page you can find the example usage for org.w3c.dom Document appendChild.

Prototype

public Node appendChild(Node newChild) throws DOMException;

Source Link

Document

Adds the node newChild to the end of the list of children of this node.

Usage

From source file:com.photon.phresco.service.tools.TechnologyDataGenerator.java

/**
 * Create pom.xml file for each module/*  ww  w  . j  a va 2  s . c om*/
 * @param module
 * @param ext
 * @param groupId2
 * @return
 * @throws PhrescoException
 */
private File createPomFile(String name, String groupId, String artifactId, String version, String ext)
        throws PhrescoException {
    System.out.println("Creating Pom File For " + name);
    File file = new File(outputRootDir, "pom.xml");
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    try {
        DocumentBuilder domBuilder = domFactory.newDocumentBuilder();

        org.w3c.dom.Document newDoc = domBuilder.newDocument();
        Element rootElement = newDoc.createElement("project");
        newDoc.appendChild(rootElement);

        Element modelVersion = newDoc.createElement("modelVersion");
        modelVersion.setTextContent("4.0.0");
        rootElement.appendChild(modelVersion);

        Element groupIdEle = newDoc.createElement("groupId");
        groupIdEle.setTextContent(groupId);
        rootElement.appendChild(groupIdEle);

        Element artifactIdEle = newDoc.createElement("artifactId");
        artifactIdEle.setTextContent(artifactId);
        rootElement.appendChild(artifactIdEle);

        Element versionEle = newDoc.createElement("version");
        versionEle.setTextContent(version);
        rootElement.appendChild(versionEle);

        Element packaging = newDoc.createElement("packaging");
        packaging.setTextContent(ext);
        rootElement.appendChild(packaging);

        Element description = newDoc.createElement("description");
        description.setTextContent("created by phresco");
        rootElement.appendChild(description);

        TransformerFactory transfac = TransformerFactory.newInstance();
        Transformer trans = transfac.newTransformer();
        trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        trans.setOutputProperty(OutputKeys.INDENT, "yes");

        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        DOMSource source = new DOMSource(newDoc);
        trans.transform(source, result);
        String xmlString = sw.toString();
        FileWriter writer = new FileWriter(file);
        writer.write(xmlString);
        writer.close();

    } catch (Exception e) {
        throw new PhrescoException();
    }
    return file;
}

From source file:com.jkoolcloud.tnt4j.streams.parsers.ActivityXmlParser.java

private Document cropDocumentForNode(Node xmlDoc) throws ParseException {
    if (xmlDoc.getParentNode() != null) { // if node is not document root node
        try {/* w  w w  . j a v a 2  s . c  o  m*/
            Document nodeXmlDoc;
            synchronized (builder) {
                nodeXmlDoc = builder.newDocument();
            }
            Node importedNode = nodeXmlDoc.importNode(xmlDoc, true);
            nodeXmlDoc.appendChild(importedNode);

            return nodeXmlDoc;
        } catch (Exception exc) {
            ParseException pe = new ParseException(StreamsResources.getString(
                    StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityXmlParser.xmlDocument.parse.error"), 0);
            pe.initCause(exc);

            throw pe;
        }
    }

    return null;
}

From source file:be.fedict.eid.applet.service.signer.ooxml.AbstractOOXMLSignatureService.java

private void addOriginSigsRels(String signatureZipEntryName, ZipOutputStream zipOutputStream)
        throws ParserConfigurationException, IOException, TransformerConfigurationException,
        TransformerFactoryConfigurationError, TransformerException {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document originSignRelsDocument = documentBuilder.newDocument();

    Element relationshipsElement = originSignRelsDocument
            .createElementNS("http://schemas.openxmlformats.org/package/2006/relationships", "Relationships");
    relationshipsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
            "http://schemas.openxmlformats.org/package/2006/relationships");
    originSignRelsDocument.appendChild(relationshipsElement);

    Element relationshipElement = originSignRelsDocument
            .createElementNS("http://schemas.openxmlformats.org/package/2006/relationships", "Relationship");
    String relationshipId = "rel-" + UUID.randomUUID().toString();
    relationshipElement.setAttribute("Id", relationshipId);
    relationshipElement.setAttribute("Type",
            "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature");
    String target = FilenameUtils.getName(signatureZipEntryName);
    LOG.debug("target: " + target);
    relationshipElement.setAttribute("Target", target);
    relationshipsElement.appendChild(relationshipElement);

    zipOutputStream.putNextEntry(new ZipEntry("_xmlsignatures/_rels/origin.sigs.rels"));
    writeDocumentNoClosing(originSignRelsDocument, zipOutputStream, false);
}

From source file:edu.mit.csail.sls.wami.relay.WamiRelay.java

public void sendReadyMessage() {
    Document doc = XmlUtils.newXMLDocument();
    Element root = doc.createElement("reply");
    root.setAttribute("type", "wami_ready");
    doc.appendChild(root);
    sendMessage(doc);//from   w  ww. j  a v  a2 s.  c o m
}

From source file:jp.co.opentone.bsol.framework.core.generator.excel.strategy.XmlWorkbookGeneratorStrategy.java

/**
 * SpreadsheetML??./*from  w  ww. j a v a 2  s .c o m*/
 * @return DOM Document
 * @throws ParserConfigurationException ??
 */
private Document createDocument() throws ParserConfigurationException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    Document doc = factory.newDocumentBuilder().newDocument();
    Map<String, String> param = new HashMap<String, String>();
    param.put("progid", "Excel.Sheet");
    ProcessingInstruction pi = doc.createProcessingInstruction("mso-application", "progid=\"Excel.Sheet\"");
    doc.appendChild(pi);

    return doc;
}

From source file:com.urbancode.x2o.xml.XmlWrite.java

public void makeXml(Object object, Document doc, Element parent) throws IllegalArgumentException,
        IllegalAccessException, InvocationTargetException, ClassNotFoundException {
    String className = object.getClass().getCanonicalName();
    String nameSpace = persistConf.getNameSpaceForClassName(className);

    String prefix = persistConf.getPrefixForNameSpace(nameSpace);

    String elemName = persistConf.getElementForClassName(className);
    Element element = doc.createElementNS(nameSpace, prefix + ":" + elemName);

    if (parent == null) {
        doc.appendChild(element);
    } else {//w w w  .j  a v a  2  s  .c  o m
        parent.appendChild(element);
    }

    List<Method> methods = findMethodsForClass("get", object.getClass());
    for (Method method : methods) {
        Object methodResult = method.invoke(object);

        // if the result is a list of Tasks,
        // then iterate through each one and write it out as a sub-element
        if (methodResult instanceof List<?>) {
            for (Task nextTask : (List<Task>) methodResult) {
                makeXml(nextTask, doc, element);
            }
        }
        // if the result is a Task,
        // then write it out as a sub-element
        else if (methodResult instanceof Task) {
            makeXml(methodResult, doc, element);
        }
        // if the result is not any of the above,
        // then write it out as an attribute
        else {
            String attrName = method.getName();
            attrName = attrName.replaceFirst("get", "");
            attrName = convertFromCamelCase(attrName);
            if (methodResult == null || "null".equals(methodResult)) {
                methodResult = "";
            }
            String resultString = methodResult.toString();
            element.setAttribute(attrName, resultString);
        }
    }
}

From source file:com.microsoft.windowsazure.management.sql.RestoreDatabaseOperationsImpl.java

/**
* Issues a restore request for an Azure SQL Database.
*
* @param sourceServerName Required. The name of the Azure SQL Database
* Server where the source database is, or was, hosted.
* @param parameters Required. Additional parameters for the Create Restore
* Database Operation request.//w w  w.jav a 2  s  .co  m
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return Contains the response to the Create Restore Database Operation
* request.
*/
@Override
public RestoreDatabaseOperationCreateResponse create(String sourceServerName,
        RestoreDatabaseOperationCreateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (sourceServerName == null) {
        throw new NullPointerException("sourceServerName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getSourceDatabaseName() == null) {
        throw new NullPointerException("parameters.SourceDatabaseName");
    }
    if (parameters.getTargetDatabaseName() == null) {
        throw new NullPointerException("parameters.TargetDatabaseName");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("sourceServerName", sourceServerName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "createAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/sqlservers/servers/";
    url = url + URLEncoder.encode(sourceServerName, "UTF-8");
    url = url + "/restoredatabaseoperations";
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPost httpRequest = new HttpPost(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/xml");
    httpRequest.setHeader("x-ms-version", "2012-03-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element serviceResourceElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "ServiceResource");
    requestDoc.appendChild(serviceResourceElement);

    Element sourceDatabaseNameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "SourceDatabaseName");
    sourceDatabaseNameElement.appendChild(requestDoc.createTextNode(parameters.getSourceDatabaseName()));
    serviceResourceElement.appendChild(sourceDatabaseNameElement);

    if (parameters.getSourceDatabaseDeletionDate() != null) {
        Element sourceDatabaseDeletionDateElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "SourceDatabaseDeletionDate");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        sourceDatabaseDeletionDateElement.appendChild(requestDoc
                .createTextNode(simpleDateFormat.format(parameters.getSourceDatabaseDeletionDate().getTime())));
        serviceResourceElement.appendChild(sourceDatabaseDeletionDateElement);
    }

    if (parameters.getTargetServerName() != null) {
        Element targetServerNameElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "TargetServerName");
        targetServerNameElement.appendChild(requestDoc.createTextNode(parameters.getTargetServerName()));
        serviceResourceElement.appendChild(targetServerNameElement);
    }

    Element targetDatabaseNameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "TargetDatabaseName");
    targetDatabaseNameElement.appendChild(requestDoc.createTextNode(parameters.getTargetDatabaseName()));
    serviceResourceElement.appendChild(targetDatabaseNameElement);

    if (parameters.getPointInTime() != null) {
        Element targetUtcPointInTimeElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "TargetUtcPointInTime");
        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
        simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
        targetUtcPointInTimeElement.appendChild(
                requestDoc.createTextNode(simpleDateFormat2.format(parameters.getPointInTime().getTime())));
        serviceResourceElement.appendChild(targetUtcPointInTimeElement);
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_CREATED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        RestoreDatabaseOperationCreateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_CREATED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new RestoreDatabaseOperationCreateResponse();
            DocumentBuilderFactory documentBuilderFactory2 = DocumentBuilderFactory.newInstance();
            documentBuilderFactory2.setNamespaceAware(true);
            DocumentBuilder documentBuilder2 = documentBuilderFactory2.newDocumentBuilder();
            Document responseDoc = documentBuilder2.parse(new BOMInputStream(responseContent));

            Element serviceResourceElement2 = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "ServiceResource");
            if (serviceResourceElement2 != null) {
                RestoreDatabaseOperation serviceResourceInstance = new RestoreDatabaseOperation();
                result.setOperation(serviceResourceInstance);

                Element requestIDElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "RequestID");
                if (requestIDElement != null) {
                    String requestIDInstance;
                    requestIDInstance = requestIDElement.getTextContent();
                    serviceResourceInstance.setId(requestIDInstance);
                }

                Element sourceDatabaseNameElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "SourceDatabaseName");
                if (sourceDatabaseNameElement2 != null) {
                    String sourceDatabaseNameInstance;
                    sourceDatabaseNameInstance = sourceDatabaseNameElement2.getTextContent();
                    serviceResourceInstance.setSourceDatabaseName(sourceDatabaseNameInstance);
                }

                Element sourceDatabaseDeletionDateElement2 = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "SourceDatabaseDeletionDate");
                if (sourceDatabaseDeletionDateElement2 != null
                        && sourceDatabaseDeletionDateElement2.getTextContent() != null
                        && !sourceDatabaseDeletionDateElement2.getTextContent().isEmpty()) {
                    Calendar sourceDatabaseDeletionDateInstance;
                    sourceDatabaseDeletionDateInstance = DatatypeConverter
                            .parseDateTime(sourceDatabaseDeletionDateElement2.getTextContent());
                    serviceResourceInstance.setSourceDatabaseDeletionDate(sourceDatabaseDeletionDateInstance);
                }

                Element targetServerNameElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "TargetServerName");
                if (targetServerNameElement2 != null) {
                    String targetServerNameInstance;
                    targetServerNameInstance = targetServerNameElement2.getTextContent();
                    serviceResourceInstance.setTargetServerName(targetServerNameInstance);
                }

                Element targetDatabaseNameElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "TargetDatabaseName");
                if (targetDatabaseNameElement2 != null) {
                    String targetDatabaseNameInstance;
                    targetDatabaseNameInstance = targetDatabaseNameElement2.getTextContent();
                    serviceResourceInstance.setTargetDatabaseName(targetDatabaseNameInstance);
                }

                Element targetUtcPointInTimeElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "TargetUtcPointInTime");
                if (targetUtcPointInTimeElement2 != null) {
                    Calendar targetUtcPointInTimeInstance;
                    targetUtcPointInTimeInstance = DatatypeConverter
                            .parseDateTime(targetUtcPointInTimeElement2.getTextContent());
                    serviceResourceInstance.setPointInTime(targetUtcPointInTimeInstance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:edu.mit.csail.sls.wami.relay.WamiRelay.java

/**
 * Default timeout functionality: send a message to the client informing it
 * of the timeout.// w w  w  .j  a v a 2 s  .c o m
 */
public void timeout() {
    Document document = XmlUtils.newXMLDocument();
    Element root = document.createElement("reply");
    root.setAttribute("type", "timeout");
    document.appendChild(root);
    sendMessage(XmlUtils.toXMLString(document));
}

From source file:de.xplib.xdbm.util.Config.java

/**
 * /*from w ww . j a  va  2  s .c  om*/
 */
public void save() {

    Document doc = null;
    try {
        doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

        Element config = (Element) doc.appendChild(doc.createElementNS(CONFIG_NS, "config"));
        config.setAttribute("xmlns", CONFIG_NS);

        Element ui = (Element) config.appendChild(doc.createElementNS(CONFIG_NS, "ui-settings"));

        Node lang = ui.appendChild(doc.createElementNS(CONFIG_NS, "language"));
        lang.appendChild(doc.createTextNode(this.locale.getLanguage()));

        Element drivers = (Element) config.appendChild(doc.createElementNS(CONFIG_NS, "drivers"));
        Iterator dIt = this.dbDrivers.keySet().iterator();
        while (dIt.hasNext()) {

            String jar = (String) dIt.next();

            Element driver = (Element) drivers.appendChild(doc.createElementNS(CONFIG_NS, "driver"));

            driver.setAttribute("jar", jar);
            driver.setAttribute("class", (String) this.dbDrivers.get(jar));

            if (!this.dbUris.containsKey(jar)) {
                continue;
            }

            String value = "";

            ArrayList uris = (ArrayList) this.dbUris.get(jar);
            for (int i = 0, l = uris.size(); i < l; i++) {
                value += uris.get(i) + "||";
            }
            value = value.substring(0, value.length() - 2);

            driver.setAttribute("uris", value);
        }

        Element conns = (Element) config.appendChild(doc.createElementNS(CONFIG_NS, "connections"));

        for (int i = 0, s = this.connections.size(); i < s; i++) {

            Connection conn = (Connection) this.connections.get(i);

            Element conne = (Element) conns.appendChild(doc.createElementNS(CONFIG_NS, "connection"));
            conne.setAttribute("jar", conn.getJarFile());
            conne.setAttribute("class", conn.getClassName());
            conne.setAttribute("uri", conn.getUri());
        }

        Element panels = (Element) config.appendChild(doc.createElementNS(CONFIG_NS, "plugins"));

        Iterator it = this.plugins.keySet().iterator();
        while (it.hasNext()) {

            PluginFile pluginFile = (PluginFile) this.plugins.get(it.next());

            Element elem = (Element) panels.appendChild(doc.createElementNS(CONFIG_NS, "plugin"));
            elem.setAttribute("jar", pluginFile.getJarFile());
            elem.setAttribute("class", pluginFile.getClassName());
            elem.setAttribute("id", pluginFile.getId());
            elem.setAttribute("position", pluginFile.getPosition());
        }
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }

    if (doc != null) {

        OutputFormat of = new OutputFormat(doc);
        of.setIndenting(true);
        of.setIndent(1);
        of.setStandalone(true);

        StringWriter sw = new StringWriter();
        XMLSerializer xs = new XMLSerializer(sw, of);
        xs.setOutputCharStream(sw);

        try {
            xs.serialize(doc);

            sw.flush();

            System.out.println(sw.toString());

            sw.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }

        try {
            FileWriter fw = new FileWriter(this.cfgFile);
            fw.write(sw.toString());
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:uk.co.markfrimston.tasktree.TaskTree.java

public void saveConfig() throws Exception {
    try {//from  w ww  .  jav a  2s  . c  o m
        DocumentBuilder builder = builderFact.newDocumentBuilder();
        Document doc = builder.newDocument();
        //doc.appendChild(doc.createTextNode("\n"));
        Element elConfig = doc.createElement("config");
        doc.appendChild(elConfig);
        elConfig.appendChild(doc.createTextNode("\n"));

        makeConfigEl(doc, elConfig, "load-url", "URL used to load task tree from remote server", loadUrl);

        makeConfigEl(doc, elConfig, "save-url", "URL used to save task tree to remote server", saveUrl);

        makeConfigEl(doc, elConfig, "merge-command",
                "Command executed to merge task tree versions. " + "Use {0} for local file, {1} for remote",
                mergeCommand);

        if (lastSyncTime == null) {
            lastSyncTime = 0L;
        }
        makeConfigEl(doc, elConfig, "last-sync", "Timestamp of last sync. Do not edit!", lastSyncTime);

        if (unsynchedChanges == null) {
            unsynchedChanges = true;
        }
        makeConfigEl(doc, elConfig, "unsynched-changes", "Changes made since last sync. Do not edit!",
                unsynchedChanges);

        elConfig.appendChild(doc.createTextNode("\n"));

        makeFilePath();
        File file = new File(filePath + CONFIG_FILENAME);
        FileOutputStream fileStream = new FileOutputStream(file);
        writeDocToStream(doc, fileStream);
        fileStream.close();
    } catch (Exception e) {
        throw new Exception("Failed to save config file: " + e.getClass().getName() + " - " + e.getMessage());
    }
}