Here you can find the source of createTextNode(Document doc, String elemName, String attrName, String attrValue, String content)
Parameter | Description |
---|---|
doc | a parameter |
elemName | a parameter |
attrName | a parameter |
attrValue | a parameter |
content | a parameter |
public static Element createTextNode(Document doc, String elemName, String attrName, String attrValue, String content)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; public class Main { /**//from w w w .ja v a 2 s . com * Creates node with given name appended by text node with content. If not * null, adds given attribute. * * @param doc * @param elemName * @param attrName * @param attrValue * @param content * @return */ public static Element createTextNode(Document doc, String elemName, String attrName, String attrValue, String content) { Element element = doc.createElement(elemName); if (attrName != null && attrValue != null) { element.setAttribute(attrName, attrValue); } Text text = doc.createTextNode(content); element.appendChild(text); return element; } }