Example usage for org.w3c.dom Node getFirstChild

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

Introduction

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

Prototype

public Node getFirstChild();

Source Link

Document

The first child of this node.

Usage

From source file:Main.java

public static final String getValue(Node node) {
    if (node == null || node.getFirstChild() == null)
        return null;
    return node.getFirstChild().getNodeValue();
}

From source file:Main.java

public static boolean getChildBooleanValue(Node node) {
    Node child = node.getFirstChild();
    return getBooleanValue(child);
}

From source file:Main.java

public static void removeAllChildren(Node node) {
    while (node.getFirstChild() != null) {
        node.removeChild(node.getFirstChild());
    }//from   www. j  a v  a2s  . co  m
}

From source file:Main.java

/**
 * Extracts the actual header node. This should be updated with each
 * API update that changes the header object, such as "ResponseHeader".
 *
 * @param soapHeader the soap header/*from ww  w .  j av  a 2s .c  o m*/
 * @return the {@code Node} that contains elements such as "responseTime"
 */
public static Node extractResponseHeaderNode(Node soapHeader) {
    if (soapHeader.getFirstChild() != null
            && soapHeader.getFirstChild().getLocalName().equals("ResponseHeader")) {
        return soapHeader.getFirstChild();
    } else {
        return soapHeader;
    }
}

From source file:Main.java

/**
 * @param n Node to look under//from  w  ww .j ava 2s. c  o  m
 * @return true if the given node contains any #text children
 */
public static boolean isTextNode(Node n) {
    for (Node ele = n.getFirstChild(); ele != null; ele = ele.getNextSibling()) {
        String name = ele.getNodeName();
        if (!name.equalsIgnoreCase("#text"))
            return false;
    }
    return true;
}

From source file:Main.java

public static String getNodeTextValue(Node node) {
    return node.getFirstChild().getNodeValue();
}

From source file:Util.java

/**
 * Renvoie le texte contenu dans un lment
 * //w  ww.j ava 2 s.c o m
 * @param node
 * @return
 */
public static String getText(final Node node) {
    Node text = node.getFirstChild();
    if (text == null)
        return "";
    return text.getNodeValue();
}

From source file:Main.java

public static boolean isTagOnly(Node node) {
    for (Node node1 = node.getFirstChild(); node1 != null; node1 = node1.getNextSibling()) {
        short word0 = node1.getNodeType();
        if (word0 == 4 || word0 == 3 || word0 == 7)
            return false;
    }//from   ww  w .  j a  v  a2  s  . com

    return true;
}

From source file:Main.java

public static Node getFirstChildElement(Node node) {
    for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child.getNodeType() != Node.TEXT_NODE) {
            return child;
        }// w  w w .  jav  a2 s.  co m
    }

    return null;
}

From source file:Main.java

/**
 * Gets the first element of a Node//  w  w  w  .  j a  v  a 2 s.  c  om
 * @param parent Node
 * @return first element of a Node
 */
public static Element getFirstElement(Node parent) {
    Node n = parent.getFirstChild();
    while (n != null && n.getNodeType() != Node.ELEMENT_NODE) {
        n = n.getNextSibling();
    }
    if (n == null) {
        return null;
    }
    return (Element) n;
}