List of utility methods to do XML Element Get by Name
Element | getElement(Document doc, String tagName, int index) Return an Element given an XML document, tag name, and index NodeList rows = doc.getDocumentElement().getElementsByTagName(tagName);
return (Element) rows.item(index);
|
Element | getElement(Document doc, String tagName, int index) get Element return getElement(doc.getDocumentElement(), tagName, index);
|
Element | getElement(Document document, Element parent, String element) get Element NodeList nl = parent.getElementsByTagName(element); if (nl.getLength() == 0) { return null; Node n = nl.item(0); if (n == null) { return null; return (Element) n; |
Element | getElement(Document document, String elementName) get Element return document.createElement(elementName);
|
Element | getElement(Document owner, String elementName, String nsURI) Returns the Element object corresponding to the given element name. NodeList nodes = nsURI != null ? owner.getElementsByTagNameNS(nsURI, elementName) : owner.getElementsByTagName(elementName); if (nodes != null && nodes.getLength() > 0) { return ((Element) nodes.item(0)); return (null); |
Element | getElement(Document parent, String name) get Element NodeList children = parent.getElementsByTagName(name); if (children.getLength() >= 1) return (Element) children.item(0); return null; |
Element | getElement(Element parent, String elementName) Get the first instance of an element by name. Element retval = null; NodeList children = parent.getElementsByTagName(elementName); if (children.getLength() > 0) { retval = (Element) children.item(0); return retval; |
Element | getElement(Element parent, String elementName) Get the first instance of an element by name. Element retval = null; NodeList children = parent.getElementsByTagName(elementName); if (children.getLength() > 0) { retval = (Element) children.item(0); return retval; |
Element | getElement(Element parent, String localname, int position) Get the child element having the supplied localname, position and namespace. return getElement(parent, localname, position, null);
|
Element | getElement(Element parent, String tagName) get Element List<Element> children = getElements(parent, tagName); if (children.isEmpty()) { return null; return (Element) children.get(0); |