Java SOAP Message printTree(NodeList childNodes, String padding, ByteArrayOutputStream byteArrayOS)

Here you can find the source of printTree(NodeList childNodes, String padding, ByteArrayOutputStream byteArrayOS)

Description

print Tree

License

Open Source License

Declaration

private static void printTree(NodeList childNodes, String padding,
            ByteArrayOutputStream byteArrayOS) 

Method Source Code

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

import java.io.ByteArrayOutputStream;

import javax.xml.soap.Node;

import org.w3c.dom.NodeList;

public class Main {
    private static void printTree(NodeList childNodes, String padding,
            ByteArrayOutputStream byteArrayOS) {
        try {//from   w  w  w. j  a  v a 2 s. c  om
            NodeList nodes = childNodes;
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = (Node) nodes.item(i);
                String name = node.getNodeName();
                if (node.hasChildNodes()) {
                    byteArrayOS.write(('\n' + padding + "<" + name + ">")
                            .getBytes());//'\n'+padding + 
                    printTree(node.getChildNodes(), padding + " ",
                            byteArrayOS);
                    byteArrayOS.write(("</" + name + ">").getBytes());
                } else {
                    byteArrayOS.write((new String((node.getNodeValue())))
                            .getBytes());//(new String((node.getTextContent()).getBytes("ISO-8859-1"), "UTF-8")).toString().getBytes());
                }
            }
        } catch (Exception e) {
        }
    }
}

Related

  1. isSOAP12(SOAPMessage soapMessage)
  2. isSOAPFault(SOAPMessage messageSOAP)
  3. printMessage(SOAPMessageContext smc)
  4. printSoapFaultException(SOAPFaultException sfe)
  5. printSOAPMessage(SOAPMessage msg, String titol)
  6. saveMimeHeaders(SOAPMessage msg, String fileName)
  7. toByteArray(SOAPMessage soapMessage)
  8. toPrettyString(SOAPMessage response)
  9. toSOAPMessage(String msgString)