List of utility methods to do XML NodeList
Node[] | convertToArray(NodeList list) convert To Array int length = list.getLength(); Node[] copy = new Node[length]; for (int n = 0; n < length; ++n) copy[n] = list.item(n); return copy; |
List | convertToElementList(org.w3c.dom.NodeList _nodeList) Convert a NodeList to a Java List of Element s. List<org.w3c.dom.Element> elemList = new ArrayList<>(); for (int i = 0; i < _nodeList.getLength(); i++) { Element elem = (org.w3c.dom.Element) _nodeList.item(i); elemList.add(elem); return elemList; |
List | copyNodeList(NodeList nodeList) Copy a given NodeList into a List ArrayList<Node> copy = new ArrayList<Node>(); int length = nodeList.getLength(); for (int i = 0; i < length; i++) { copy.add((Node) nodeList.item(i)); return copy; |
Collection | createNodeCollection(final NodeList nodeList) create Node Collection return new Collection<Node>() { @Override public int size() { return nodeList.getLength(); @Override public boolean isEmpty() { return nodeList.getLength() > 0; ... |
List | createRealNodeList(NodeList nodeList) create Real Node List List<Node> realNodeList = new LinkedList<Node>(); if (null != nodeList && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); ++i) { Node nextNode = nodeList.item(i); realNodeList.add(nextNode); return realNodeList; ... |
boolean | equalNodes(NodeList sourceNodeList, NodeList targetNodeList) equal Nodes ArrayList sourceNodes = new ArrayList(); ArrayList targetNodes = new ArrayList(); getAllNodes(sourceNodeList, sourceNodes); getAllNodes(targetNodeList, targetNodes); int sourceLength = sourceNodes.size(); int targetLength = targetNodes.size(); if (sourceLength != targetLength) { return false; ... |
List | extractElementsFromNodeList(NodeList config, String tag, boolean required) extract Elements From Node List List<Element> res = new ArrayList<Element>(); for (int i = 0; i < config.getLength(); i++) { Node n = config.item(i); if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals(tag)) { res.add((Element) config.item(i)); if (required && res.size() == 0) { ... |
NodeList | extractNodeListFromElement(Element config, String tag, boolean required) extract Node List From Element NodeList node = config.getElementsByTagName(tag);
return check1Most(node, tag, required);
|
void | fillHashtable(NodeList list, Hashtable fill Hashtable for (int curElemNum = 0; curElemNum < list.getLength(); curElemNum++) { if (list.item(curElemNum).getNodeType() != Node.ELEMENT_NODE) continue; Element curValue = (Element) list.item(curElemNum); String valueName = curValue.getNodeName(); String value = curValue.getFirstChild().getNodeValue(); fillIn.put(valueName, value); |
void | fillHashtable(NodeList list, Hashtable fill Hashtable for (int curElemNum = 0; curElemNum < list.getLength(); curElemNum++) { if (list.item(curElemNum).getNodeType() != Node.ELEMENT_NODE) continue; Element curValue = (Element) list.item(curElemNum); String valueName = curValue.getNodeName(); String value = curValue.getFirstChild().getNodeValue(); fillIn.put(valueName, value); |