Here you can find the source of createElement(Document owner, String nsURI, String elementName, String textValue)
Parameter | Description |
---|---|
owner | Document object to own the Element object. |
nsURI | Namespace URI to use. |
elementName | local name of Element object to create. |
textValue | text value of the new Element object. |
public static Element createElement(Document owner, String nsURI, String elementName, String textValue)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { /**/* w ww . j a v a2 s. c o m*/ * Creates an Element object in the CyberSource namespace. * * @param owner Document object to own the Element object. * @param nsURI Namespace URI to use. * @param elementName local name of Element object to create. * @param textValue text value of the new Element object. * @return the newly created Element object. */ public static Element createElement(Document owner, String nsURI, String elementName, String textValue) { Attr attr = owner.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns"); attr.setValue(nsURI); Element elem = owner.createElementNS(nsURI, elementName); elem.setAttributeNodeNS(attr); elem.appendChild(owner.createTextNode(textValue)); return (elem); } }