Example usage for org.w3c.dom Node getTextContent

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

Introduction

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

Prototype

public String getTextContent() throws DOMException;

Source Link

Document

This attribute returns the text content of this node and its descendants.

Usage

From source file:Main.java

public static String getText(Node node) {
    if (node == null) {
        return null;
    }//from  ww w .  ja  v  a  2  s .co  m
    return node.getTextContent();
}

From source file:Main.java

public static String getTextContent(Node node) {
    if (node == null) {
        return null;
    }//from   w  w w  .  jav  a 2 s . c o  m
    return node.getTextContent();
}

From source file:Main.java

private static String getNodeValue(Node node, String fieldName) {
    Node targetNode = findNode(node, fieldName);

    return targetNode != null ? targetNode.getTextContent() : null;
}

From source file:Main.java

public static Map<String, String> getChildElements(Node parent) {
    Map<String, String> elements = new HashMap<String, String>();

    NodeList children = parent.getChildNodes();

    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        elements.put(child.getNodeName(), child.getTextContent());
    }/* w  ww .j  a va 2 s. c  o m*/

    return elements;
}

From source file:Main.java

public static String readTrimedText(Node element) {
    if (element == null)
        return "";
    else//www. j  a  v a 2s.  c o m
        return element.getTextContent().trim();
}

From source file:Main.java

public static String readText(Node element) {
    if (element == null)
        return "";
    else/*from ww w .  j av a  2s .c  om*/
        return element.getTextContent();
}

From source file:org.springsource.ide.eclipse.commons.content.core.util.ContentUtil.java

public static String getTextValue(Node node) {
    String text = node.getTextContent().trim();
    text = text.replaceAll("\\n", "");
    text = text.replaceAll("\\s+", " ");
    return text;//from   ww  w.  ja v a 2  s  .c  o m
}

From source file:Main.java

public static String getDescendentText(Node node, String name) throws IOException {
    Node d = getDescendent(node, name);
    if (d != null) {
        return d.getTextContent().trim();
    }/*from   w  ww .j  a  va2 s .c  om*/
    return null;
}

From source file:Main.java

public static List<String> getChildrenElementText(Node node, String childTag) {
    ArrayList<String> stringList = new ArrayList<String>();
    if (node == null)
        return stringList;
    List<Node> list = getChildNodes(node, childTag);
    for (Node n : list) {
        if (n != null)
            stringList.add(n.getTextContent().trim());
    }/*from  ww w  .  j  av  a  2s  .  com*/
    return stringList;
}

From source file:Main.java

public static String getText(Node node) {
    if (node == null)
        return "";
    return node.getTextContent();
}