List of utility methods to do XML Element Text
String | getElementText(Element element, String tagName, String namespace) get Element Text Element e = getElement(element, tagName, namespace); if (e != null) { String text = ((Element) e).getTextContent().trim(); if (text != null) { text = text.trim(); if (text.length() > 0) { return text; return null; |
String | getElementText(Element elm) get Element Text Node node = elm.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); return null; |
String | getElementText(Element elm) get Element Text Node node = elm.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) { return node.getNodeValue(); return null; |
String | getElementText(Element elm) get Element Text Node node = elm.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); return null; |
String | getElementText(Element n) get Element Text NodeList childNodes = n.getChildNodes(); String result = new String(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.TEXT_NODE) { result += node.getNodeValue(); return result; |
String | getElementText(Element namedElement) get Element Text if (namedElement == null) { return null; String text = namedElement.getTextContent(); return (text.isEmpty()) ? null : text; |
String | getElementText(Element root, String tagname) This methods extracts the text for a named element under the root .
NodeList nameList = root.getElementsByTagName(tagname); if (nameList.getLength() > 0) { Node text = nameList.item(0).getFirstChild(); while ((text != null) && !(text instanceof Text)) { text = text.getNextSibling(); if (text == null) { return null; ... |
String | getElementText(final Element element) Returns the text within a specified element. final StringBuffer elementText = new StringBuffer(256); for (Node childNode = element.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) { if (childNode.getNodeType() == Node.TEXT_NODE) { final Text textNode = (Text) childNode; elementText.append(textNode.getData()); } else if (childNode.getNodeType() == Node.CDATA_SECTION_NODE) { final CDATASection cdataNode = (CDATASection) childNode; elementText.append(cdataNode.getData()); ... |
String | getElementTextByTagName(Element n, String elementName) get Element Text By Tag Name Element subEl = getElementByTagName(n, elementName); if (subEl != null) return getElementText(subEl); return null; |
String | getElementTextDataNoEx(Element element, boolean unindent) get Element Text Data No Ex String result = null; try { result = getElementTextData(element); if (unindent) result = unindentTextData(result); } catch (Exception e) { return result; ... |