public static synchronized ArrayNodeList getChildNodes( Node node, short type, boolean caseSensitive, String filter) { ArrayNodeList rtn = new ArrayNodeList(); NodeList nodes = node.getChildNodes(); int len = nodes.getLength(); Node n; for (int i = 0; i < len; i++) { try { n = nodes.item(i); if (n != null && n.getNodeType() == type) { if (filter == null || (caseSensitive ? filter.equals(n.getLocalName()) : filter.equalsIgnoreCase(n.getLocalName()))) rtn.add(n); } } catch (Throwable t) { } } return rtn; }
/** * return all Element Children of a node * * @param node node to get children from * @return all matching child node */ public static Element[] getChildElementsAsArray(Node node) { ArrayNodeList nodeList = (ArrayNodeList) getChildNodes(node, Node.ELEMENT_NODE); return (Element[]) nodeList.toArray(new Element[nodeList.getLength()]); }
public static Node[] getChildNodesAsArray( Node node, short type, boolean caseSensitive, String filter) { ArrayNodeList nodeList = (ArrayNodeList) getChildNodes(node, type, caseSensitive, filter); return (Node[]) nodeList.toArray(new Node[nodeList.getLength()]); }
/** * return all Children of a node by a defined type as Node Array * * @param node node to get children from * @param type type of returned node * @param filter * @param caseSensitive * @return all matching child node */ public static Node[] getChildNodesAsArray(Node node, short type) { ArrayNodeList nodeList = (ArrayNodeList) getChildNodes(node, type); return (Node[]) nodeList.toArray(new Node[nodeList.getLength()]); }