Here you can find the source of addElementFirst(final Element parent, final String name)
public static Element addElementFirst(final Element parent, final String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 IBH SYSTEMS GmbH./* w w w . jav a 2s . com*/ * 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 addElementFirst(final Element parent, final String name) { final Element ele = parent.getOwnerDocument().createElement(name); parent.insertBefore(ele, null); return ele; } }