List of utility methods to do XML Child Element Text
Set | getChildElementsTextSet(Element parentElement, String tagName) Returns a Set of text content of all descendant Elements with a given tag name Null is returned if there is no child element with given tag name List<Element> childElements = getChildElements(parentElement, tagName); if (childElements != null && childElements.size() > 0) { Set<String> textList = new HashSet<String>(childElements.size()); for (Element element : childElements) { textList.add(element.getTextContent().trim()); return textList; return Collections.EMPTY_SET; |
String | getChildElementText(Element element, String name) Returns the text content for the child element with the specified name for the specified element. NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { Element childElement = (Element) node; if (childElement.getNodeName().equals(name)) { return childElement.getTextContent(); return null; |
String | GetChildElementText(Element element, String name, String defaultValue) Get Child Element Text if (element != null && name != null && !name.isEmpty()) { NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node instanceof Element && name.equals(node.getNodeName())) { return node.getTextContent(); return defaultValue; |
String | getChildElementText(Element elm, String name, String defaultValue) get Child Element Text String result = getChildElementText(elm, name);
return result == null ? defaultValue : result;
|
String | getChildElementText(Element elm, String name, String defaultValue) get Child Element Text String result = getChildElementText(elm, name);
return result == null ? defaultValue : result;
|
String | getChildElementText(Element parentElement, String tagName) This method returns the child element text. Element element = getChildElement(parentElement, tagName); if (element != null) { return getText(element); } else { return null; |
String | getChildElementText(final Element elParent, final String childTag) Returns the text within the child element with the specified tag. final Element elChild = getFirstChildOfType(elParent, childTag); if (elChild == null) { return null; return getElementText(elChild); |
String | getChildElementText(final Element parent, final String childName, final String defaultText) get Child Element Text Element child = getChildElement(parent, childName);
return child == null ? defaultText : child.getTextContent();
|
String | getChildElementText(Node node, String childName) get Child Element Text Element child = getChildElement(node, childName); if (child != null) { return getTextContent(child); return null; |
String[] | getChildElementTextArr(Element parent, String name) Returns an array of text values of a child element. List children = getChildElementsByName(parent, name); String str[] = new String[children.size()]; for (int i = 0; i < children.size(); i++) { Node child = (Node) children.get(i); StringBuffer buf = new StringBuffer(); NodeList nodes = child.getChildNodes(); for (int j = 0; j < nodes.getLength(); j++) { Node node = nodes.item(j); ... |