List of utility methods to do XML Element Get
Element | getElementByName(Element ele, String name) Get child element by name, ignoring namespace declarations List<Element> list = getElementsByName(ele, name); if (list.size() > 0) return list.get(0); return null; |
Element | getElementByQualifiedName(Element n, String namespace, String elementName) Gets the first child Element with a given name NodeList subNodes = n.getElementsByTagNameNS(namespace, elementName); int sz = subNodes.getLength(); if (sz > 0) { return (Element) subNodes.item(0); return null; |
Element | getElementByTagName(Element current, String name) get Element By Tag Name return getElementByTagName(current, name, null);
|
Element | getElementByTagName(Element el, String tag) get Element By Tag Name NodeList nl = el.getElementsByTagName(tag); if (nl.getLength() > 0) { return (Element) nl.item(0); return null; |
Element | getElementByTagName(Element el, String tag) Gets the element by tag name. NodeList nl = el.getElementsByTagName(tag); if (nl.getLength() > 0) { return (Element) nl.item(0); return null; |
String | getElementByTagName(Element elem, String name, String emptyValue) Get text data of first XML org.w3c.dom.Element of given name. NodeList nodeList = elem.getElementsByTagName(name); if (nodeList.getLength() == 0) { return null; NodeList children = nodeList.item(0).getChildNodes(); if (children.getLength() == 0 || children.item(0).getNodeType() != Node.TEXT_NODE) { return emptyValue; return children.item(0).getNodeValue(); |
Element | getElementByTagName(Element element, String name) get Element By Tag Name NodeList nodes = element.getElementsByTagName(name); if (nodes.getLength() == 0) return null; else return (Element) nodes.item(0); |
Element | getElementByTagName(Element element, String name, int index) get Element By Tag Name NodeList list = element.getElementsByTagName(name);
return (Element) list.item(index);
|
Element | getElementByTagName(Element element, String tag) get single element by tag name NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Element && ((Element) node).getTagName().equals(tag)) { return (Element) node; return null; ... |
Element | getElementByTagName(Element element, String tag) get single element by tag name. NodeList list = element.getElementsByTagName(tag); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Element) { return (Element) node; return null; ... |