Here you can find the source of addAsFirstChild(Element element, Element newChild)
public static void addAsFirstChild(Element element, Element newChild)
//package com.java2s; /**// w w w.j a va 2 s.co m * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed * license file for more information. */ import org.w3c.dom.Element; public class Main { public static void addAsFirstChild(Element element, Element newChild) { if (element.hasChildNodes()) { element.insertBefore(newChild, element.getChildNodes().item(0)); } else { element.appendChild(newChild); } } }