List of utility methods to do XML Child Element Text
boolean | getChildTextAsBoolean(Element parent, String childName, boolean defValue) get Child Text As Boolean try { String value = getChildText(parent, childName); if (value != null) { if (value.trim().equals("1")) { return true; if (value.trim().equals("0")) { return false; ... |
Boolean | getChildTextAsBooleanObj(Element parent, String childName, Boolean defValue) Get the text content of a given child name as a java.lang.Boolean value. try { String value = getChildText(parent, childName); if (value != null) { return Boolean.valueOf(value); } catch (Exception ex) { return defValue; ... |
String | getChildTextByName(Element parent, String name) Equivalent to getTextContent(getFirstChildByName(e, n)), with a null check. Element e = getFirstChildByName(parent, name);
return (e != null) ? getTextContent(e) : null;
|
String | getChildTextByTagName(Element e, String tagName) get Child Text By Tag Name Element child = getChildByTagName(e, tagName); if (child != null) { return getText(child); return null; |
String | getChildTextContent(Element elemenet, String childElemenetName) get Child Text Content return org.springframework.util.xml.DomUtils.getChildElementValueByTagName(elemenet, childElemenetName);
|
String | getChildTextContent(Element element, String childTagName) Gets the text content of a child element for a tag name or null if not found. Element childElem = getChildElementByTagName(element, childTagName);
return childElem == null ? null : childElem.getTextContent();
|
List | getChildTextList(Element elem, String childTagName) Return list of content Strings of all child elements with given tag name. NodeList nodeList = elem.getElementsByTagName(childTagName); int len = nodeList.getLength(); if (len == 0) { return Collections.EMPTY_LIST; } else { List list = new ArrayList(len); for (int i = 0; i < len; i++) { list.add(getElementText((Element) nodeList.item(i))); ... |
Text | getChildTextNode(Element el) Gets the child text node containing character data for the given DOM element. if (el == null) return null; NodeList list = el.getChildNodes(); int size = list.getLength(); for (int i = 0; i < size; i++) { Node node = list.item(i); if (!(node instanceof Text)) continue; ... |
List | getChildTextNodes(Element parent) get Child Text Nodes ArrayList<Text> retval = new ArrayList<Text>(); Node n = parent.getFirstChild(); while (n != null) { if (n instanceof Text) { retval.add((Text) n); n = n.getNextSibling(); return retval; |
String | getChildTextNodeValue(Node node) Returns value of single child text node or null .
if (node.getChildNodes().getLength() != 1) { return null; Node item0 = node.getChildNodes().item(0); if (item0.getNodeType() != Node.TEXT_NODE) { return null; return item0.getNodeValue(); ... |