List of utility methods to do XML NodeList
String | getTextContent(NodeList nodeList) get Text Content Node node = getFirstNode(nodeList); if (node == null) return null; return node.getTextContent(); |
String | getTextFields(NodeList list) Extracts all text values from a list of Element nodes. StringBuffer sb = new StringBuffer(""); for (int i = 0; i < list.getLength(); i++) { Node node = (Node) list.item(i); if (i > 0) sb.append("\n"); sb.append(getTextValue(node)); return sb.toString(); ... |
String | getXmlNodeValue(NodeList nodeList) Extract the node string representation. String retObj = null; if (nodeList != null && nodeList.getLength() > 0) { Element element = (Element) nodeList.item(0); if (element != null && element.getChildNodes() != null) { NodeList childNodes = element.getChildNodes(); if (childNodes != null && childNodes.getLength() > 0) { retObj = ((Node) childNodes.item(0)).getNodeValue(); return retObj; |
boolean | hasElementNodes(NodeList list) Check whether there are any element nodes in a NodeList final int length = list.getLength(); for (int i = 0; i < length; i++) { if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { return true; return false; |
boolean | hasImageNodes(NodeList nodeList) has Image Nodes for (int i = 0; i < nodeList.getLength(); i++) { Node n = nodeList.item(i); if (n != null) { if (n.getNodeType() == Node.ELEMENT_NODE) { Element element = ((Element) n); String tag = element.getTagName(); if ("img".equals(tag) || "object".equals(tag)) { return true; ... |
int | indexOf(NodeList nodeList, String tagName, int startIdx) index Of for (int i = startIdx; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { if (node.getNodeName().equals(tagName)) { return i; return -1; |
boolean | isEmpty(@Nullable final NodeList aNL) is Empty return aNL == null ? true : aNL.getLength() == 0;
|
boolean | isEmpty(NodeList nl) Test if node list is null or empty. return nl == null || nl.getLength() == 0;
|
boolean | isListEmpty(NodeList list) is List Empty return list.getLength() == 0;
|
boolean | isNodeListEmpty(final NodeList nodeList) is Node List Empty return nodeList == null || nodeList.getLength() == 0;
|