Example usage for org.w3c.dom Node getNodeName

List of usage examples for org.w3c.dom Node getNodeName

Introduction

In this page you can find the example usage for org.w3c.dom Node getNodeName.

Prototype

public String getNodeName();

Source Link

Document

The name of this node, depending on its type; see the table above.

Usage

From source file:Main.java

public static boolean isValidNode(Node node) {
    return !node.getNodeName().equals("#text");
}

From source file:Main.java

public static boolean isDocument(Node node) {
    return "#document".equals(node.getNodeName());
}

From source file:Main.java

/**
 * Checks if the name of a node matches with a given string
 *
 * @param n node whose name has to be checked
 * @param name supposed name for the node
 * @return {@literal true} if the name of the node matches the name passed
 * as a parameter// ww  w  .j a va2  s . c  o m
 */
public static boolean isNodeName(Node n, String name) {
    return n.getNodeName().compareTo(name) == 0;
}

From source file:Main.java

public static boolean hasSameNamedSibling(Node node) {
    String s = node.getNodeName();
    for (Node node1 = node.getPreviousSibling(); node1 != null; node1 = node1.getPreviousSibling())
        if (node1.getNodeName().equals(s) && node1.getNodeType() == node.getNodeType())
            return true;

    for (Node node2 = node.getNextSibling(); node2 != null; node2 = node2.getNextSibling())
        if (node2.getNodeName().equals(s) && node2.getNodeType() == node.getNodeType())
            return true;

    return false;
}

From source file:Main.java

public static void removeElement(Element parent, String tagName) {
    NodeList nl = parent.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node nd = nl.item(i);
        if (nd.getNodeName().equals(tagName)) {
            parent.removeChild(nd);/*from w  w  w. jav  a  2  s. c om*/
        }
    }
}

From source file:Main.java

private static String getNodeNameWithNamespace(Node node) {
    String name = node.getNodeName();
    String ns = node.getNamespaceURI();
    String prefix = (ns != null) ? node.lookupPrefix(ns) : null;
    if ((prefix != null) && !name.startsWith(prefix + ":")) {
        name = prefix + ":" + name;
    }//from ww w.  j a v a  2s . c  o m
    return name;
}

From source file:Main.java

private static Boolean qtyWarehouseConditions(Node node) {
    return node.getNodeName().equalsIgnoreCase("BEGINING") || node.getNodeName().equalsIgnoreCase("INCOMING")
            || node.getNodeName().equalsIgnoreCase("OUTGOING") || node.getNodeName().equalsIgnoreCase("ENDING");
}

From source file:Main.java

public static Node getChildNode(Node parentNode, String childElementName) {
    NodeList l = parentNode.getChildNodes();
    for (int i = 0; i < l.getLength(); i++) {
        Node node = l.item(i);
        if (node.getNodeName().equals(childElementName))
            return node;
    }/*from  w ww. j  a  v  a 2  s  .  c  o m*/
    return null;
}

From source file:Main.java

private static Boolean qtyProductionConditions(Node node) {
    return node.getNodeName().equalsIgnoreCase("RAW_MATERIAL")
            || node.getNodeName().equalsIgnoreCase("TOTAL_MATERIALS")
            || node.getNodeName().equalsIgnoreCase("TOTAL_PRODUCTS");
}

From source file:Main.java

private static <T> void printArrayContent(Node[] t) {

    for (Node o : t) {

        System.out.println(o.getNodeName());
    }/*from  w  ww  .j  ava  2  s  . c o m*/
}