Java XML Format printNodeToConsole(Node n, ByteArrayOutputStream byteArrayOS)

Here you can find the source of printNodeToConsole(Node n, ByteArrayOutputStream byteArrayOS)

Description

print Node To Console

License

Open Source License

Declaration

public static void printNodeToConsole(Node n,
            ByteArrayOutputStream byteArrayOS) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

import java.util.Properties;

import javax.xml.soap.Node;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

public class Main {
    public static void printNodeToConsole(Node n,
            ByteArrayOutputStream byteArrayOS) {
        try {//from  ww  w  .  j  a v a  2s  .co  m
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            Properties oform = new Properties();
            oform.setProperty("encoding", "ISO-8859-1");

            //oform.setOmitXMLDeclaration(true);
            transformer.setOutputProperties(oform);
            // also print to console
            transformer.transform(new DOMSource(n), new StreamResult(
                    byteArrayOS));
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Related

  1. printNode(Node n)
  2. printNode(Node node)
  3. printNode(Node node, String fn)
  4. printNode(OutputStream out, Node node, boolean prettyPrint, boolean includeXmlDeclaration)
  5. printNodeSubtreeXMLString(final Node node)
  6. printReply(SOAPMessage reply)
  7. printStream(InputStream is)
  8. printXML(Node node)
  9. xmlFormat(String xml)