Java XML Duration Add addElement(final Element parent, final String name, final Object value)

Here you can find the source of addElement(final Element parent, final String name, final Object value)

Description

add Element

License

Open Source License

Declaration

public static Element addElement(final Element parent, final String name, final Object value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 IBH SYSTEMS GmbH./* ww  w  .ja v  a2  s . c  om*/
 * 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 addElement(final Element parent, final String name) {
        final Element ele = parent.getOwnerDocument().createElement(name);
        parent.appendChild(ele);
        return ele;
    }

    public static Element addElement(final Element parent, final String name, final Object value) {
        final Element ele = addElement(parent, name);
        if (value != null) {
            ele.setTextContent(value.toString());
        }
        return ele;
    }
}

Related

  1. add(Duration d1, Duration d2)
  2. add(Duration... durations)
  3. addElement(Element parent, String name)
  4. addElement(Element parent, String tagName)
  5. addElement(Node parent, String elementName)
  6. addElement(Node parent, String name)
  7. addElement(String name, Element parent)
  8. addElementFirst(final Element parent, final String name)