Here you can find the source of addTextElement(final Document document, final Element parentDom, final String namespace, final String name, final String value)
Parameter | Description |
---|---|
document | root document |
parentDom | parent node |
namespace | namespace |
name | element name |
value | element text node value |
public static Element addTextElement(final Document document, final Element parentDom, final String namespace, final String name, final String value)
//package com.java2s; //License from project: LGPL import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; public class Main { /**//www.j av a 2s .co m * This method creates and adds a new XML {@code Element} with text value * * @param document * root document * @param parentDom * parent node * @param namespace * namespace * @param name * element name * @param value * element text node value * @return added element */ public static Element addTextElement(final Document document, final Element parentDom, final String namespace, final String name, final String value) { final Element dom = document.createElementNS(namespace, name); parentDom.appendChild(dom); final Text valueNode = document.createTextNode(value); dom.appendChild(valueNode); return dom; } }