Java XML Child Element Create addElement(final Document dom, final Element el, final String name, final String value)

Here you can find the source of addElement(final Document dom, final Element el, final String name, final String value)

Description

add Element

License

Open Source License

Declaration

public static Element addElement(final Document dom, final Element el, final String name, final String value) 

Method Source Code

//package com.java2s;
/*//from   w ww. j  a  v  a  2 s .com
 *  Copyright (C) 2006-2015  Ronald Blankendaal
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static Element addElement(final Document dom, final Element el, final String name, final String value) {
        Element newElement = dom.createElement(name);
        newElement.appendChild(dom.createTextNode(value));
        el.appendChild(newElement);
        return el;
    }
}

Related

  1. addElement(Document document, Element parentElement, String elementName, String elementValue)
  2. addElement(final Document doc, final Node parent, final String name)
  3. addElement(final Document document, final Element parentDom, final String namespace, final String name)
  4. addElement(final Document document, final Element parentDom, final String namespace, final String name)
  5. addElement(final Document document, final Element root, final String elementValue, final String elementName)
  6. addElementAndSetContent(Document doc, String name, Element parent, String text)
  7. addElementChildToElement(Document doc, Element parent, String elementName)
  8. addElementWithText(Document document, Element parentElement, String newElementName, String textString)
  9. appendDateNode(Document owner, Element appendElement, String name, Date date)