/** * Return an array of String representing each Text element of the nodes * which are in the list. * * @param list * @return */ public static List<String> getTextContents(final NodeList list) { List<String> result = null; if (list != null) { result = new ArrayList<String>(); for (int i = 0; i < list.getLength(); i++) { Node pathElement = list.item(i); if (pathElement.getNodeType() != Node.TEXT_NODE) { result.add(getTextContent(pathElement)); } } } return result; }