List of utility methods to do XML Element Get from Parent
int | getElementIntValue(Document document, Element parent, String string) get Element Int Value return Integer.parseInt(getElementStringValue(document, parent, string));
|
Element[] | getElements(Document document, Element parent) get Elements if (parent == null) { return new Element[] {}; NodeList nl = parent.getChildNodes(); ArrayList al = new ArrayList(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n instanceof Element) { ... |
Element[] | getElements(Document document, Element parent) get Elements if (parent == null) { return new Element[] {}; NodeList nl = parent.getChildNodes(); return toElements(nl); |
String | getElementStringValue(Document document, Element parent, String element) get Element String Value NodeList nl = parent.getElementsByTagName(element); if (nl.getLength() == 0) { return ""; Node n = nl.item(0).getFirstChild(); if (n == null) { return ""; return n.getNodeValue(); |
String | getElementValueByTagName(Document doc, String parentName, String eleName) get Element Value By Tag Name NodeList nl = doc.getElementsByTagName(parentName); if (null == nl) { return null; Node item = nl.item(0); return getChildElementValueByTagName((Element) item, eleName); |
Element | getFirstElement(Node parent) Gets the first element of a Node Node n = parent.getFirstChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getNextSibling(); if (n == null) { return null; return (Element) n; ... |
Element | getFirstElement(Node parent) get First Element Node n = parent.getFirstChild(); while (n != null && Node.ELEMENT_NODE != n.getNodeType()) { n = n.getNextSibling(); if (n == null) { return null; return (Element) n; ... |
Node | getFirstNode(final Node parent, final String... path) get First Node List<Node> nodes = getNodes(parent, path); if (nodes == null) return null; if (nodes.size() == 0) return null; return nodes.get(0); |
String | getNamedElemValue(Element parent, String elementName) get Named Elem Value String val = null; NodeList list = parent.getElementsByTagName(elementName); if (list.getLength() > 0) { val = ((Element) list.item(0)).getTextContent(); return val; |
NodeList | getNamedNodeList(Element parent, String containerTagName) Retrieves the DOM NodeList contained by the named element in the given parent element.In the above example, a NodeList containing the two elements would be returned by passing the parent element and "named-list" into the function parameters. NodeList nl = parent.getElementsByTagName(containerTagName); if (nl.getLength() < 1) { throw new Exception("Missing named list: " + containerTagName); return nl.item(0).getChildNodes(); |