List of utility methods to do XML Node Select
Element | selectElement(Node node, String uri, String nodeName) select Element while (node != null) { if (nodeName.equals(node.getLocalName()) && uri.equals(node.getNamespaceURI())) return (Element) node; Element located = findElementinChilds(node, uri, nodeName); if (located != null) { return located; return null; |
Node | selectNode(Node node, String tag) select Node NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); if (n instanceof Element && ((Element) n).getTagName().equals(tag)) { return n; return null; ... |
Element | selectNode(Node sibling, String uri, String nodeName, int number) select Node while (sibling != null) { if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri) && sibling.getLocalName().equals(nodeName)) { if (number == 0) { return (Element) sibling; number--; sibling = sibling.getNextSibling(); return null; |
Element | selectNode(Node sibling, String uri, String nodeName, int number) select Node while (sibling != null) { if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri) && sibling.getLocalName().equals(nodeName)) { if (number == 0) { return (Element) sibling; number--; sibling = sibling.getNextSibling(); return null; |
Element | selectNode(Node sibling, String uri, String nodeName, int number) select Node while (sibling != null) { if (nodeName.equals(sibling.getLocalName()) && uri.equals(sibling.getNamespaceURI())) { if (number == 0) { return (Element) sibling; number--; sibling = sibling.getNextSibling(); ... |
Node | selectNodeByName(Node node, String nodeName) Method selectNodeByName. Node nodeToReturn = null; int i = 0; NodeList currNodes = node.getChildNodes(); int length = currNodes.getLength(); while ((i < length) && (nodeToReturn == null)) { Node thisNode = currNodes.item(i); if (thisNode.getNodeName().equals(nodeName)) { nodeToReturn = thisNode; ... |
Element[] | selectNodes(Node sibling, String uri, String nodeName) select Nodes List<Element> list = new ArrayList<Element>(); while (sibling != null) { if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri) && sibling.getLocalName().equals(nodeName)) { list.add((Element) sibling); sibling = sibling.getNextSibling(); return list.toArray(new Element[list.size()]); |
Element[] | selectNodes(Node sibling, String uri, String nodeName) select Nodes int size = 20; Element[] a = new Element[size]; int curr = 0; while (sibling != null) { if (nodeName.equals(sibling.getLocalName()) && uri.equals(sibling.getNamespaceURI())) { a[curr++] = (Element) sibling; if (size <= curr) { int cursize = size << 2; ... |
Text | selectNodeText(Node sibling, String uri, String nodeName, int number) select Node Text Node n = selectNode(sibling, uri, nodeName, number); if (n == null) { return null; n = n.getFirstChild(); while (n != null && n.getNodeType() != Node.TEXT_NODE) { n = n.getNextSibling(); return (Text) n; |
Text | selectNodeText(Node sibling, String uri, String nodeName, int number) select Node Text Node n = selectNode(sibling, uri, nodeName, number); if (n == null) { return null; n = n.getFirstChild(); while (n != null && n.getNodeType() != Node.TEXT_NODE) { n = n.getNextSibling(); return (Text) n; |