Java XML Element Print printElement(SOAPElement el)

Here you can find the source of printElement(SOAPElement el)

Description

recursively print element

License

Common Public License

Parameter

Parameter Description
el a parameter

Declaration

static private void printElement(SOAPElement el) 

Method Source Code

//package com.java2s;
/*/*ww  w .  j  a v  a  2s  .  co  m*/
 * ====================================================================
 * This software is subject to the terms of the Common Public License
 * Agreement, available at the following URL:
 *   http://www.opensource.org/licenses/cpl.html .
 * Copyright (C) 2003-2004 TONBELLER AG.
 * All Rights Reserved.
 * You must accept the terms of that agreement to use this software.
 * ====================================================================
 *
 * 
 */

import java.util.Iterator;

import javax.xml.soap.SOAPElement;

public class Main {
    /**
     * recursively print element
     * @param el
     */
    static private void printElement(SOAPElement el) {

        System.out.println(el.getElementName() + el.getValue());
        Iterator itAtt = el.getAllAttributes();
        if (itAtt.hasNext()) {
            System.out.print("<" + el.getElementName());
            while (itAtt.hasNext()) {
                SOAPElement att = (SOAPElement) itAtt.next();
                System.out.print(" " + att.getElementName() + "=" + att.getValue());
            }
            System.out.println(">");
        } else {
            System.out.println("<" + el.getElementName() + ">");
        }

        System.out.println(el.getValue());
        System.out.println("</" + el.getElementName() + ">");

        Iterator it = el.getChildElements();
        while (it.hasNext()) {
            SOAPElement element = (SOAPElement) it.next();
            printElement(element);
        }
    }
}

Related

  1. printElement(Element e)
  2. printElementBody(Element elem, StringWriter sw)
  3. printElementEnd(Element elem, StringWriter sw)
  4. printElementStart(Element elem, StringWriter sw)
  5. printElemShallow(Element elem, String endient, PrintStream pstrm)