Java XML Child Element Create addElementAndSetContent(Document doc, String name, Element parent, String text)

Here you can find the source of addElementAndSetContent(Document doc, String name, Element parent, String text)

Description

add Element And Set Content

License

Open Source License

Declaration

public static Element addElementAndSetContent(Document doc, String name, Element parent, String text) 

Method Source Code

//package com.java2s;
/* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under
 * the Apache 2.0 License, see http://coconut.codehaus.org/license.
 *//*  ww w  .  j a v  a 2s.c  o m*/

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

public class Main {
    public static Element addElementAndSetContent(Document doc, String name, Element parent, String text) {
        Element ee = addElement(doc, name, parent);
        ee.setTextContent(text);
        return ee;
    }

    public static Element addElement(Document doc, String name, Element parent) {
        Element ee = doc.createElement(name);
        parent.appendChild(ee);
        return ee;
    }
}

Related

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