List of utility methods to do XML Node Child Get
ArrayList | children(Node x) children ArrayList<Element> a = new ArrayList<Element>(); NodeList nodeList = x.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node n = nodeList.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { a.add((Element) n); return a; |
ArrayList | childrenOfType(Node x, String s) children Of Type ArrayList<Element> a = new ArrayList<Element>(); Node n = x.getFirstChild(); Node last = x.getLastChild(); while (n != null) { if (n.getNodeName().equals(s)) { a.add((Element) n); if (n == last) ... |
Element | firstChildOfType(Node x, String s) first Child Of Type if (x != null) { Node n = x.getFirstChild(); Node last = x.getLastChild(); while (n != null) { if (n.getNodeName().equals(s)) { return (Element) n; if (n == last) ... |
List | getMatchingChildNodes(Node node, String nodeName, String attributeName, List get Matching Child Nodes if (node == null || nodeName == null) { return null; List<Node> nodes = new ArrayList(); NodeList nodeList = node.getChildNodes(); int i = 0; while (i < nodeList.getLength()) { Node childNode = nodeList.item(i); ... |
Element | firstDescendantOfType(Node x, String s) first Descendant Of Type Node n = firstChildOfType(x, s); if (n != null) return (Element) n; n = (Element) x.getFirstChild(); Node last = x.getLastChild(); while (n != null) { Element k = firstDescendantOfType((Node) n, s); if (k != null) ... |
String | firstValueOfType(Node x, String s) first Value Of Type Node n = x.getFirstChild(); Node last = x.getLastChild(); while (n != null) { if (n.getNodeName().equals(s)) { NodeList nodes = n.getChildNodes(); String result = ""; for (int i = 0; i < nodes.getLength(); i++) { Node m = nodes.item(i); ... |
void | getSet(Node rootNode, Set get Set if ((exclude != null) && isDescendantOrSelf(exclude, rootNode)) { return; getSetRec(rootNode, result, exclude, com); |
void | getSetRec(final Node rootNode, final Set get Set Rec if (rootNode == exclude) { return; switch (rootNode.getNodeType()) { case Node.ELEMENT_NODE: result.add(rootNode); Element el = (Element) rootNode; if (el.hasAttributes()) { ... |