Code example for Element

Methods: appendChild, getOwnerDocument

0
  } 
 
  /** Append an HTML <input type="hidden"> to the form. */ 
  public static void addHidden(final Element form, final String name,
      final String value) {
    final Element in = form.getOwnerDocument().createElement("input");
    in.setAttribute("type", "hidden");
    in.setAttribute("name", name);
    in.setAttribute("value", value);
    form.appendChild(in);
  } 
 
  /** Construct a new empty document. */ 
  public static Document newDocument() {
    try { 
      return newBuilder().newDocument();
    } catch (ParserConfigurationException e) {
      throw new RuntimeException("Cannot create new document", e);
    } 
  }