Java XML Node Type getTypeAsString(Node node, boolean cftype)

Here you can find the source of getTypeAsString(Node node, boolean cftype)

Description

returns the Node Type As String

License

LGPL

Parameter

Parameter Description
node a parameter
cftype a parameter

Declaration

public static String getTypeAsString(Node node, boolean cftype) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import org.w3c.dom.Node;

public class Main {
    /**//from w w w. ja  v  a2  s .co m
     * returns the Node Type As String
     * @param node
    * @param cftype 
    * @return
     */
    public static String getTypeAsString(Node node, boolean cftype) {
        String suffix = cftype ? "" : "_NODE";

        switch (node.getNodeType()) {
        case Node.ATTRIBUTE_NODE:
            return "ATTRIBUTE" + suffix;
        case Node.CDATA_SECTION_NODE:
            return "CDATA_SECTION" + suffix;
        case Node.COMMENT_NODE:
            return "COMMENT" + suffix;
        case Node.DOCUMENT_FRAGMENT_NODE:
            return "DOCUMENT_FRAGMENT" + suffix;
        case Node.DOCUMENT_NODE:
            return "DOCUMENT" + suffix;
        case Node.DOCUMENT_TYPE_NODE:
            return "DOCUMENT_TYPE" + suffix;
        case Node.ELEMENT_NODE:
            return "ELEMENT" + suffix;
        case Node.ENTITY_NODE:
            return "ENTITY" + suffix;
        case Node.ENTITY_REFERENCE_NODE:
            return "ENTITY_REFERENCE" + suffix;
        case Node.NOTATION_NODE:
            return "NOTATION" + suffix;
        case Node.PROCESSING_INSTRUCTION_NODE:
            return "PROCESSING_INSTRUCTION" + suffix;
        case Node.TEXT_NODE:
            return "TEXT" + suffix;
        default:
            return "UNKNOW" + suffix;
        }
    }
}

Related

  1. getNodeType(Node node)
  2. getNodeType(Node node)
  3. getNodeType(Node node)
  4. getNodeTypeStr(int nodeType)
  5. getSubnodesOfType(Node in, int type)
  6. getTypeName(Node nameNode)
  7. getTypeName(short nodeType)
  8. hasParentNodeType(Node n, String tagToMatch)
  9. mapNodeType(short nodeType)