Here you can find the source of xmlNewDocument(final String tagName)
Parameter | Description |
---|---|
tagName | the tag name |
public static final Element xmlNewDocument(final String tagName)
//package com.java2s; /**//from w ww . j a v a2 s . com * Copyright (C) 2011-2012 Barchart, Inc. <http://www.barchart.com/> * * All rights reserved. Licensed under the OSI BSD License. * * http://www.opensource.org/licenses/bsd-license.php */ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { private static final ThreadLocal<DocumentBuilder> XML_BUILDER = new ThreadLocal<DocumentBuilder>() { @Override protected DocumentBuilder initialValue() { try { final DocumentBuilder builder = DocumentBuilderFactory .newInstance().newDocumentBuilder(); return builder; } catch (final Exception e) { throw new RuntimeException(e); } } }; /** * Xml new document. * * @param tagName * the tag name * @return the element */ public static final Element xmlNewDocument(final String tagName) { final Document doc = XML_BUILDER.get().newDocument(); final Element tag = doc.createElement(tagName); return tag; } }