Here you can find the source of addElement(final Element parent, final String name, final Object value)
public static Element addElement(final Element parent, final String name, final Object value)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 IBH SYSTEMS GmbH./* ww w .ja v a2 s . c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBH SYSTEMS GmbH - initial API and implementation *******************************************************************************/ import org.w3c.dom.Element; public class Main { public static Element addElement(final Element parent, final String name) { final Element ele = parent.getOwnerDocument().createElement(name); parent.appendChild(ele); return ele; } public static Element addElement(final Element parent, final String name, final Object value) { final Element ele = addElement(parent, name); if (value != null) { ele.setTextContent(value.toString()); } return ele; } }