List of utility methods to do XML NodeList
int | getCurrentListPosition(Node refNode, NodeList list) returns an element's position in the given NodeList if (refNode == null) { return -1; int counter = 1; for (int n = 0; n < list.getLength(); n++, counter++) { if (list.item(n) == refNode) { return counter; return -1; |
Node | getDeepNode(String name[], NodeList nodes) get Deep Node for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeName().equalsIgnoreCase(name[0])) { if (name.length == 1) { return node; } else { return getDeepNode(name, node.getChildNodes(), 1); return null; |
ArrayList | getDSNameListInScriptText(String scriptText, NodeList tableList) get DS Name List In Script Text ArrayList<String> fieldList = new ArrayList<String>(); int pos, posWrk, wrkInt, posWrk2; String[] sectionDigit = { "(", ")", "{", "}", "+", "-", "/", "*", "=", "<", ">", ";", "|", "&", "\n", "\t", ",", " ", "!" }; String[] fieldProperty = { "value", "oldValue", "color", "enabled", "editable", "error", "valueChanged" }; boolean isFirstDigitOfField; String variantExpression, wrkStr1, wrkStr2, dataSource; org.w3c.dom.Element element; ... |
Element | getElementById(NodeList nodeList, String id) Get Element that has attribute id="xyz". Element element = null; int len = nodeList.getLength(); for (int i = 0; i < len; i++) { Node node = (Node) nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { element = (Element) node; if (((Element) node).getAttribute("id").equals(id)) { break; ... |
Element | getElementFromItem(NodeList list, int index) Get Element from Nodelist return (Element) list.item(index);
|
Element | getElementFromNodeList(NodeList nl) Selects the (first) element from a node list and returns it. if ((nl == null) || (nl.getLength() == 0)) { return null; for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; return null; |
List | getElementList(NodeList list) Filters all elements of a NodeList and returns them in a collection. List<Element> col = new ArrayList<>(list.getLength()); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { col.add((Element) list.item(i)); return col; |
List | getElements(NodeList nodeList, String localname, String namespaceURI) Get the child elements having the supplied localname and namespace. int count = nodeList.getLength(); Vector elements = new Vector(); for (int i = 0; i < count; i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (localname.equals("*") || getName(element).equals(localname)) { if (namespaceURI == null || namespaceURI.equals(element.getNamespaceURI())) { ... |
List | getElementsFromNodeList(final NodeList nodeList) get Elements From Node List final List<Element> elements = new ArrayList<>(); for (int i = 0; i < nodeList.getLength(); i++) { final Node node = nodeList.item(i); if (node instanceof Element) { elements.add((Element) node); return elements; ... |
Element[] | getElementsOfNodeList(NodeList nodeList) Returns an array containing the element objects in the provided node list. Element[] ret = null; @SuppressWarnings("rawtypes") Vector v = new Vector(); for (int n = 0; n < nodeList.getLength(); n++) { Node item = nodeList.item(n); if (item.getNodeType() == Node.ELEMENT_NODE) { v.addElement(item); ret = new Element[v.size()]; for (int n = 0; n < ret.length; n++) { ret[n] = (Element) v.elementAt(n); return ret; |