Here you can find the source of getNodeValue(Node node, String name, boolean trim)
public static String getNodeValue(Node node, String name, boolean trim)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getNodeValue(Node node, String name) { return getNodeValue(node, name, true); }/* w w w. ja va 2s .c om*/ public static String getNodeValue(Node node, String name, boolean trim) { String retValue = null; NodeList element = ((Element) node).getElementsByTagName(name); if (element.getLength() > 0) { NodeList valueNodeList = ((Element) element.item(0)).getChildNodes(); if (valueNodeList.getLength() > 0) { retValue = valueNodeList.item(0).getNodeValue(); } } return (trim && (retValue != null)) ? retValue.trim() : retValue; } }