Java XML Element Create createText(final Node parent, final String text)

Here you can find the source of createText(final Node parent, final String text)

Description

Creates the text.

License

Open Source License

Parameter

Parameter Description
parent the parent
text the text

Return

the text

Declaration

public static Text createText(final Node parent, final String text) 

Method Source Code

//package com.java2s;
/***********************************************************************************************************************
 * Copyright (c) 2008 empolis GmbH and brox IT Solutions GmbH. 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: Ivan Churkin (brox IT Solutions GmbH) - initial creator
 *               Sebastian Voigt (brox IT Solutions GmbH)
 *               Andreas Weber (empolis GmbH) - switch to XML 1.1 in header to make more documents readable.
 **********************************************************************************************************************/

import org.w3c.dom.Node;
import org.w3c.dom.Text;

public class Main {
    /**/*from w w w.  j  a v a 2  s  .  com*/
     * Creates the text.
     *
     * @param parent
     *          the parent
     * @param text
     *          the text
     *
     * @return the text
     */
    public static Text createText(final Node parent, final String text) {
        final Text child = parent.getOwnerDocument().createTextNode(text);
        parent.appendChild(child);
        return child;
    }
}

Related

  1. createElmWithText(Document doc, String tagName, String text)
  2. createNewElementAndSetAndAttribute(Document document, Element parent, String childElement, String childValue, String attributeName, String attributeValue)
  3. createNode(Document doc, Element parent, String nodeName, Object[] attr)
  4. createNode(Document doc, Element parent, String nodeName, Object[] attr)
  5. createTable(Element theParent)
  6. createText(Node parent, String tag, String text)
  7. createText(String sValue, Node nParent)
  8. createTextElement(Element parent, String tagName, String text)
  9. createTextElement2(Element parent, String tagName, String text)