Here you can find the source of prependChild(Element parent, Element child)
Parameter | Description |
---|---|
parent | a parameter |
child | a parameter |
public static void prependChild(Element parent, Element child)
//package com.java2s; //License from project: LGPL import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/* ww w . j a va 2s .c om*/ * adds a child at the first place * @param parent * @param child */ public static void prependChild(Element parent, Element child) { Node first = parent.getFirstChild(); if (first == null) parent.appendChild(child); else { parent.insertBefore(child, first); } } }