Java XML Node Print printlnCommon(Node n)

Here you can find the source of printlnCommon(Node n)

Description

println Common

License

Open Source License

Declaration

public static void printlnCommon(Node n) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 UNIT Information Technologies R&D Ltd
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/* ww w.j a v  a  2 s .  c  o  m*/
 *     Ferhat Erata - initial API and implementation
 *     H. Emre Kirmizi - initial API and implementation
 *     Serhat Celik - initial API and implementation
 *     U. Anil Ozturk - initial API and implementation
 *******************************************************************************/

import org.w3c.dom.Node;

public class Main {
    public static void printlnCommon(Node n) {
        System.out.print(" nodeName=\"" + n.getNodeName() + "\"");

        String val = n.getNamespaceURI();
        if (val != null) {
            System.out.print(" uri=\"" + val + "\"");
        }

        val = n.getPrefix();

        if (val != null) {
            System.out.print(" pre=\"" + val + "\"");
        }

        val = n.getLocalName();
        if (val != null) {
            System.out.print(" local=\"" + val + "\"");
        }

        val = n.getNodeValue();
        if (val != null) {
            System.out.print(" nodeValue=");
            if (val.trim().equals("")) {
                // Whitespace
                System.out.print("[WS]");
            } else {
                System.out.print("\"" + n.getNodeValue() + "\"");
            }
        }
        System.out.println();
    }
}

Related

  1. printDifferences(Node node1, Node node2)
  2. printDOM(Node node)
  3. printDOM(Node node, String prefix)
  4. printDOMTree(Node node, PrintStream out)
  5. printElement(Node node, int level)
  6. printNode(final String indent, final Node node)
  7. printNode(Node aNode, int aLevel)
  8. printNode(Node node)
  9. printNode(Node node)