List of utility methods to do XML Node Type
Node[] | getSubnodesOfType(Node in, int type) get Subnodes Of Type NodeList subnodes = in.getChildNodes(); if (subnodes == null) return (new Node[0]); int count = subnodes.getLength(); List holder = new ArrayList(); for (int i = 0; i < count; i++) { Node test = subnodes.item(i); if (test.getNodeType() == type) ... |
String | getTypeAsString(Node node, boolean cftype) returns the Node Type As String String suffix = cftype ? "" : "_NODE"; switch (node.getNodeType()) { case Node.ATTRIBUTE_NODE: return "ATTRIBUTE" + suffix; case Node.CDATA_SECTION_NODE: return "CDATA_SECTION" + suffix; case Node.COMMENT_NODE: return "COMMENT" + suffix; ... |
String | getTypeName(Node nameNode) get Type Name Node firstChild = nameNode.getFirstChild(); if (firstChild == null) { return null; String nodeValue = firstChild.getNodeValue(); String nameType = ""; if (nodeValue != null && !nodeValue.trim().isEmpty()) { nameType = nodeValue + "."; ... |
String | getTypeName(short nodeType) Returns the node type name from the node type code switch (nodeType) { case Node.ELEMENT_NODE: return "element"; case Node.DOCUMENT_NODE: return "document"; case Node.TEXT_NODE: return "text"; case Node.ATTRIBUTE_NODE: ... |
boolean | hasParentNodeType(Node n, String tagToMatch) has Parent Node Type Node parent = n.getParentNode(); while (parent != null) { if (parent.getNodeType() == Node.ELEMENT_NODE) { Element element = ((Element) parent); String tag = element.getTagName(); if (tagToMatch.equals(tag)) { return true; parent = parent.getParentNode(); return false; |
String | mapNodeType(short nodeType) Maps a node type, as returned by to a name. assert nodeType < nodeTypeMap.length; String val = nodeTypeMap[nodeType]; if (val == null) val = "UNKNOWN!!!"; assert val instanceof String; return (String) val; |