List of utility methods to do XML Node Name
Set | getNodeNames(Set get Node Names Set<String> names = new HashSet<String>(); for (Node node : nodes) { names.add(node.getLocalName()); return names; |
String | getNodeNameWithNamespace(Node node) get Node Name With Namespace String name = node.getNodeName(); String ns = node.getNamespaceURI(); String prefix = (ns != null) ? node.lookupPrefix(ns) : null; if ((prefix != null) && !name.startsWith(prefix + ":")) { name = prefix + ":" + name; return name; |
Vector | getNodes(Node iNode, String iNodeName) This method returns an ordered list containing the desired nodes which is determined by the provided node name and namespace. Logger.getLogger("org.adl.util.debug.validator").entering("DOMTreeUtility", "getNodes()"); Logger.getLogger("org.adl.util.debug.validator").info("Parent Node: " + iNode.getLocalName()); Logger.getLogger("org.adl.util.debug.validator").info("Node being searched for: " + iNodeName); Vector result = new Vector(); if (iNode != null) { NodeList children = iNode.getChildNodes(); if (children != null) { int numChildren = children.getLength(); ... |
ArrayList | getNodes(Node module, String interfaceName, String nodeName) Gets all nodes of a module that are child of a given interface and have a specific name Node iFace = getInterfaceNodeByName(interfaceName, module); NodeList childs = iFace.getChildNodes(); ArrayList<Node> operations = new ArrayList<Node>(); Node child; for (int i = 0; i < childs.getLength(); i++) { child = childs.item(i); if (child.getNodeName().equals(nodeName)) { operations.add(child); ... |
Iterator | getNodes(Node node, String nodeName) Searches parent node for matching child nodes. ArrayList nodes = new ArrayList(); NodeList nl = node.getChildNodes(); int nll = nl.getLength(); for (int i = 0; i < nll; i++) { Node n = nl.item(i); if (n.getNodeName().equals(nodeName)) { nodes.add(n); return nodes.iterator(); |
String | getSimpleName(final Node node) Gets XML node name. return node.getLocalName() == null ? node.getNodeName().substring(node.getNodeName().indexOf(':') + 1) : node.getLocalName(); |
List | getSubNodes(Node node, String subNodeName) get Sub Nodes List<Node> nodes = new ArrayList<Node>(); NodeList list_child = node.getChildNodes(); for (int ck = 0; ck < list_child.getLength(); ck++) { Node tmpNode = list_child.item(ck); if (tmpNode.getNodeName() != null && tmpNode.getNodeName().equals(subNodeName)) { nodes.add(tmpNode); return nodes; |
String | getSubNodeValue(Node node, String nodeName, String subNodeName) Searches parent node 2 levels deep and returns the first match node's value. Node subNode = getNode(node, nodeName); if (subNode == null) { return null; return getNodeValue(subNode, subNodeName); |
String | getTagName(Node labelNode) get Tag Name if (labelNode.getNodeType() == Node.ELEMENT_NODE) { return labelNode.getNodeName(); return null; |
String | getTagName(Node node) get Tag Name if (node instanceof Element) return ((Element) node).getTagName(); else return null; |