Here you can find the source of addElementFirst(final Element parent, final String name)
Parameter | Description |
---|---|
parent | the parent to which to add the element |
name | the name of the element |
public static Element addElementFirst(final Element parent, final String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014, 2015 IBH SYSTEMS GmbH. * 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:// www . jav a 2s .c o m * IBH SYSTEMS GmbH - initial API and implementation *******************************************************************************/ import org.w3c.dom.Element; public class Main { /** * Create a new element and add it as the first child * * @param parent * the parent to which to add the element * @param name * the name of the element * @return the new element */ public static Element addElementFirst(final Element parent, final String name) { final Element ele = parent.getOwnerDocument().createElement(name); parent.insertBefore(ele, null); return ele; } }