List of usage examples for org.dom4j.io XMLWriter XMLWriter
public XMLWriter(OutputFormat format) throws UnsupportedEncodingException
From source file:org.apache.openmeetings.installation.InstallationDocumentHandler.java
License:Apache License
public static void createDocument(int stepNo) throws Exception { Document document = DocumentHelper.createDocument(); Element root = document.addElement("install"); Element step = root.addElement("step"); step.addElement("stepnumber").addText("" + stepNo); step.addElement("stepname").addText("Step " + stepNo); try (OutputStream os = new FileOutputStream(OmFileHelper.getInstallFile())) { XMLWriter writer = new XMLWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8)); writer.write(document);// www .j a va 2 s .c o m writer.close(); } }
From source file:org.apache.taglibs.xtags.servlet.XPathServlet.java
License:Apache License
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType(XML_MIME_TYPE); try {//from w ww . j a va 2 s.co m if (writer == null) { writer = new XMLWriter(outputFormat); } writer.setOutputStream(response.getOutputStream()); writer.write(createDocument(request)); writer.flush(); } catch (ServletException e) { throw e; } catch (IOException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }