Here you can find the source of createTextElement(final Document document, final String tagName, final String text)
Parameter | Description |
---|---|
document | the document to contain the new element |
tagName | the element's tag name (required) |
text | the text to set; can be <code>null</code> for none |
null
element
public static Element createTextElement(final Document document, final String tagName, final String text)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { /**//from www.j a v a 2 s .c o m * Creates an {@link Element} containing the given text * * @param document the document to contain the new element * @param tagName the element's tag name (required) * @param text the text to set; can be <code>null</code> for none * @return a non-<code>null</code> element * @since 1.2.0 */ public static Element createTextElement(final Document document, final String tagName, final String text) { final Element element = document.createElement(tagName); element.setTextContent(text); return element; } }