How to declare doctype ,xml version and encoding in XML file using DOM parser in java?
问题 For sorry, I don't know how to attempt to do such thing. public void writeXML(String tableName) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); // root elements Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(tableName); doc.appendChild(rootElement); for(Map m: rows){ Element parent = doc.createElement((String) m.get("ownerNode")); rootElement.appendChild(parent);