Here you can find the source of createElement(QName qName)
Parameter | Description |
---|---|
qName | A QName object. |
public static Element createElement(QName qName)
//package com.java2s; //License from project: Apache License import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { /**/*from www . j a v a 2 s. c om*/ * Creates a new Element having the specified qualified name. The element * must be {@link Document#adoptNode(Node) adopted} when inserted into * another Document. * * @param qName A QName object. * @return An Element node (with a Document owner but no parent). */ public static Element createElement(QName qName) { Document doc = null; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } Element elem = doc.createElementNS(qName.getNamespaceURI(), qName.getLocalPart()); return elem; } }