List of utility methods to do XML Element Get Value
String | getTextContent(Element element) get Text Content return org.springframework.util.xml.DomUtils.getTextValue(element);
|
String | getTextContent(Element element) Obtain the text content of an element. return getTextContent(element, true);
|
String | getTextContentFromFirstElementByTagName(Element element, String tagName) get Text Content From First Element By Tag Name return getTrimmedTextContent(getFirstElementByTagName(element, tagName));
|
String | getTextContentOfElement(Element elem, String tagName, boolean required) get Text Content Of Element List<String> result = getTextContentOfElements(elem, tagName); if (result.isEmpty() && !required) return null; if (result.size() != 1) throw new IOException("expected exactly one " + tagName + " element"); return result.get(0); |
List | getTextContentOfElements(Element elem, String tagName) get Text Content Of Elements List<String> result = new ArrayList<String>(); NodeList inputElems = elem.getElementsByTagName(tagName); for (int i = 0; i < inputElems.getLength(); i++) { Element childElem = (Element) inputElems.item(i); result.add(childElem.getTextContent()); return result; |
String | getTextContents(Element e) get Text Contents if (!e.hasChildNodes()) return null; StringBuffer buf = new StringBuffer(); NodeList list = e.getChildNodes(); int len = list.getLength(); String text; for (int i = 0; i < len; i++) { text = ((Node) list.item(i)).getNodeValue(); ... |
String | getTextData(Element element) get Text Data NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if ((childNodes.item(i).getNodeType() == Node.TEXT_NODE) || (childNodes.item(i).getNodeType() == Node.CDATA_SECTION_NODE)) { if (childNodes.item(i) != null) { String tmpStr = ((Text) childNodes.item(i)).getWholeText().trim(); if (tmpStr.length() > 0) { return tmpStr; ... |
String | getTextElementValue(Element ele) get Text Element Value StringBuffer buffer = new StringBuffer(); Node node = ele.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.TEXT_NODE) { buffer.append(node.getNodeValue()); } else if (node.getNodeType() == Node.CDATA_SECTION_NODE) { buffer.append(node.getNodeValue()); node = node.getNextSibling(); return buffer.toString(); |
String | getTextFromFirstSubEleByName(Element element, String tagName) get Text From First Sub Ele By Name List<Element> childEle = getSubElementByName(element, tagName); for (int i = 0; i < childEle.size(); i++) { String tmp = getTextData(childEle.get(i)); if (tmp != null) return tmp; return null; |
String | getTextFromTag(Element current, String tag) Return the inner text from the given tag if (current == null) return ""; String result = ""; NodeList nodes = current.getElementsByTagName(tag); if (nodes.getLength() > 0) result = ((Element) nodes.item(0)).getTextContent(); return result; |