List of utility methods to do XML Element Get Value
void | getText(final Element element, final StringBuilder sbuf, final boolean decend) Get the text content of an element. Node node = element.getFirstChild(); while (node != null) { switch (node.getNodeType()) { case Node.TEXT_NODE: sbuf.append(node.getNodeValue()); break; case Node.ELEMENT_NODE: if (decend) { ... |
String | getText(final Element tag) Looks for a text child node and returns its value. if (tag == null) return null; NodeList lst = tag.getChildNodes(); StringBuffer buf = new StringBuffer(); for (int Index = 0, Cnt = lst.getLength(); Index < Cnt; Index++) { if (lst.item(Index).getNodeType() == Node.ENTITY_REFERENCE_NODE) { buf.append(lst.item(Index).getChildNodes().item(0).getNodeValue()); if ((lst.item(Index).getNodeType() == Node.TEXT_NODE) || (lst.item(Index).getNodeType() == Node.CDATA_SECTION_NODE)) { buf.append(lst.item(Index).getNodeValue()); if (buf.length() == 0) return null; else return buf.toString(); |
String | getTextContent(Element e) get Text Content String ret = null; boolean found = false; StringBuffer buffer = new StringBuffer(); NodeList childList = e.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node child = childList.item(i); if (child.getNodeType() != Node.TEXT_NODE) continue; ... |
String | getTextContent(Element e, String name) get Text Content NodeList nl = e.getElementsByTagName(name); try { return (nl != null && nl.getLength() > 0) ? nl.item(0).getTextContent().trim() : null; } catch (NullPointerException ex) { return null; |
String | getTextContent(Element el) Returns a string representing the plain text content of an element. StringBuffer sb = new StringBuffer(); for (Node child = el.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof Text) { Text childText = (Text) child; sb.append(childText.getData()); return sb.toString(); ... |
String | getTextContent(Element ele) get Text Content NodeList list = ele.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return node.getTextContent(); return ""; ... |
String | getTextContent(Element element) get Text Content NodeList children = element.getChildNodes(); for (int i = 0, max = children.getLength(); i < max; i++) { Node node = children.item(i); if (node instanceof Text) { Text text = (Text) node; return text.getData(); return ""; |
String | getTextContent(Element element) Returns the value of any text nodes stored as children of the given element NodeList children = element.getChildNodes(); StringBuffer result = new StringBuffer(); for (int i = 0; i < children.getLength(); ++i) { Node currentNode = children.item(i); if (currentNode.getNodeType() == Node.TEXT_NODE) { result.append(currentNode.getNodeValue()); return result.toString(); |
String | getTextContent(Element element) get Text Content StringBuilder buffer = new StringBuilder(); element.normalize(); NodeList children = element.getChildNodes(); for (int i = 0, n = children.getLength(); i < n; i++) { Node child = children.item(i); if (child.getNodeType() == Node.TEXT_NODE) { buffer.append(child.getNodeValue()); return buffer.toString().trim(); |
String | getTextContent(Element element) get Text Content final NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node node = childNodes.item(i); if (node instanceof Text) { String textContent = ((Text) node).getWholeText(); textContent = textContent.trim(); return textContent; return null; |