Here you can find the source of getTextContent(Node node, String defaultValue)
Parameter | Description |
---|---|
node | The node. |
defaultValue | The default value. |
public static String getTextContent(Node node, String defaultValue)
//package com.java2s; //License from project: Creative Commons License import org.w3c.dom.Node; public class Main { /**/*from w w w . jav a 2 s . c o m*/ * Returns the text content of a node or an empty string if an error occurs. * * @param node The node. * @return The text content or an empty string. */ public static String getTextContent(Node node) { return getTextContent(node, ""); } /** * Returns the text content of a node or an empty string if an error occurs. * * @param node The node. * @param defaultValue The default value. * @return The text content or the default value. */ public static String getTextContent(Node node, String defaultValue) { try { String content = null; if (node != null) { content = node.getTextContent(); } return content != null ? content : defaultValue; } catch (Exception e) { return defaultValue; } } }