Here you can find the source of appendNewElement(Document document, Element parent, String element, Object content, String namespace)
public static Element appendNewElement(Document document, Element parent, String element, Object content, String namespace)
//package com.java2s; /*/*from w w w . j a v a 2s. c o m*/ * Copyright (C) 2013 4th Line GmbH, Switzerland * * The contents of this file are subject to the terms of either the GNU * Lesser General Public License Version 2 or later ("LGPL") or the * Common Development and Distribution License Version 1 or later * ("CDDL") (collectively, the "License"). You may not use this file * except in compliance with the License. See LICENSE.txt for more * information. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import org.w3c.dom.*; public class Main { public static Element appendNewElement(Document document, Element parent, Enum el) { return appendNewElement(document, parent, el.toString()); } public static Element appendNewElement(Document document, Element parent, String element) { Element child = document.createElement(element); parent.appendChild(child); return child; } public static Element appendNewElement(Document document, Element parent, String element, Object content) { return appendNewElement(document, parent, element, content, null); } public static Element appendNewElement(Document document, Element parent, String element, Object content, String namespace) { Element childElement; if (namespace != null) { childElement = document.createElementNS(namespace, element); } else { childElement = document.createElement(element); } if (content != null) { // TODO: We'll have that on Android 2.2: // childElement.setTextContent(content.toString()); // Meanwhile: childElement.appendChild(document.createTextNode(content .toString())); } parent.appendChild(childElement); return childElement; } }