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 Double getAttributeValueAsDouble(Node node, String attributeName, Double defaultValue) {
    final Node attributeNode = node.getAttributes().getNamedItem(attributeName);
    return attributeNode != null ? Double.parseDouble(attributeNode.getTextContent()) : defaultValue;
}

From source file:Main.java

public static String getNodeContent(String NodeRawname, Element element) {
    Node tmpNode = element.getElementsByTagName(NodeRawname).item(0);
    if (tmpNode != null)
        return tmpNode.getTextContent().trim();
    else/*  ww  w  .  jav a2 s. com*/
        return null;
}

From source file:Main.java

public static String getRequestID(String xml) throws ParserConfigurationException, SAXException, IOException {

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    Node reqName = document.getElementsByTagName("request-id").item(0);
    if (reqName != null)
        return reqName.getTextContent();
    else/*from  www. ja v  a  2 s.co  m*/
        return null;
}

From source file:Main.java

public static String getUnicastID(String xml) throws ParserConfigurationException, SAXException, IOException {

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    Node reqName = document.getElementsByTagName("unicast-id").item(0);
    if (reqName != null)
        return reqName.getTextContent();
    else/*w w w  .  ja  va 2  s .com*/
        return null;
}

From source file:Main.java

/**
 * Get textual content of a node(for text nodes only).
 * //from w  w  w.j  av  a2  s  . c  o  m
 * @param node a text node.
 * @return node's textual content.
 */
public static String getNodeValue(Node node) {
    NodeList childNodes = node.getChildNodes();
    for (int x = 0; x < childNodes.getLength(); x++) {
        Node data = childNodes.item(x);
        if (data.getNodeType() == Node.TEXT_NODE)
            return data.getTextContent();
    }
    return "";
}

From source file:Main.java

public static Integer getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue) {
    final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

    return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : defaultValue;
}

From source file:Main.java

public static Integer getAttributeValueAsInteger(Node node, String attributeName) {
    final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

    return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : null;
}

From source file:Main.java

public static String getRequestName(String xml) throws ParserConfigurationException, SAXException, IOException {

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    Node reqName = document.getElementsByTagName("request-name").item(0);
    if (reqName != null)
        return reqName.getTextContent();
    else//w  w  w  .  j a  v a  2s  .  co m
        return null;
}

From source file:Main.java

public static Boolean getAttributeValueAsBoolean(Node node, String attributeName, Boolean defaultValue) {
    final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

    return attributeNode != null ? Boolean.parseBoolean(attributeNode.getTextContent()) : defaultValue;
}

From source file:Main.java

public static Boolean getAttributeValueAsBoolean(Node node, String attributeName) {
    final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

    return attributeNode != null ? Boolean.parseBoolean(attributeNode.getTextContent()) : null;
}