Here you can find the source of createDocument(String docElt)
Parameter | Description |
---|---|
docElt | name of the document element |
public static Document createDocument(String docElt)
//package com.java2s; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.bootstrap.DOMImplementationRegistry; public class Main { private static DOMImplementation impl; private static DOMImplementationRegistry registry; /**//w w w.j av a 2 s.com * Creates a new DOM document. * * @param docElt * name of the document element * @return a new DOM document */ public static Document createDocument(String docElt) { getImplementation(); return impl.createDocument("", docElt, null); } /** * Creates a new instance of the DOM registry and get an implementation of DOM 3 with Load Save * objects. */ private static void getImplementation() { try { if (registry == null) { registry = DOMImplementationRegistry.newInstance(); } if (impl == null) { impl = registry.getDOMImplementation("Core 3.0 XML 3.0 LS"); if (impl == null) { throw new RuntimeException("no DOM 3 implementation found"); } } } catch (ClassNotFoundException e) { throw new RuntimeException("DOM error", e); } catch (InstantiationException e) { throw new RuntimeException("DOM error", e); } catch (IllegalAccessException e) { throw new RuntimeException("DOM error", e); } } }