Java XML DOM Print prettyPrintDOMAsHTML(Node node, OutputStream stream)

Here you can find the source of prettyPrintDOMAsHTML(Node node, OutputStream stream)

Description

pretty Print DOM As HTML

License

BSD License

Declaration

public static void prettyPrintDOMAsHTML(Node node, OutputStream stream) throws TransformerException 

Method Source Code


//package com.java2s;
/*/*from   w  w  w  .  j  a  v a  2  s .c om*/
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;

public class Main {
    public static void prettyPrintDOMAsHTML(Node node, OutputStream stream) throws TransformerException {
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty(OutputKeys.METHOD, "html");
        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        transformer.transform(new DOMSource(node), new StreamResult(stream));
    }
}

Related

  1. prettyPrintDOM(Node node)
  2. prettyPrintDOM(Node node, OutputStream stream)
  3. printDom(Node dom, OutputStream os)
  4. printDOM(Node node, OutputStream out, String encoding)
  5. printDOM(Node root, OutputStream os)
  6. printDOMTree(Node node, PrintWriter out, String docType, String copyright)