Java XML Node Type getTypeName(Node nameNode)

Here you can find the source of getTypeName(Node nameNode)

Description

get Type Name

License

Open Source License

Declaration

private static String getTypeName(Node nameNode) 

Method Source Code

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

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static String getTypeName(Node nameNode) {

        Node firstChild = nameNode.getFirstChild();
        if (firstChild == null) {
            return null;
        }// w w  w. j a  v  a  2 s . c  om

        String nodeValue = firstChild.getNodeValue();
        String nameType = "";
        if (nodeValue != null && !nodeValue.trim().isEmpty()) {
            nameType = nodeValue + ".";
        } else if (nameNode.getChildNodes().getLength() > 1) {
            NodeList childNodes2 = nameNode.getChildNodes();
            for (int j = 0; j < childNodes2.getLength(); j++) {
                Node child = childNodes2.item(j);
                if (!"name".equalsIgnoreCase(child.getNodeName())) {
                    continue;
                }

                String nodeValue2 = getTypeName(child);
                nameType += nodeValue2;
            }
        }
        return nameType;
    }
}

Related

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