List of utility methods to do XML Child Node Get
List | getChildNodesByName(Node element, String name, boolean caseSensitive) Helper Method. ArrayList<Node> nodes = new ArrayList<Node>(); NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (caseSensitive) { if (node.getNodeName().equals(name)) nodes.add(node); } else { ... |
List | getChildNodesByName(Node element, String name, boolean caseSensitive) Helper Method. ArrayList<Node> nodes = new ArrayList<Node>(); NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (caseSensitive) { if (node.getNodeName().equals(name)) nodes.add(node); } else { ... |
List | getChildNodesByName(Node node, String name) get Child Nodes By Name List<Node> result = new ArrayList<Node>(); NodeList childList = node.getChildNodes(); for (int i = 0; i < childList.getLength(); ++i) { Node child = childList.item(i); if (child.getNodeName().equals(name)) { result.add(child); return result; |
NodeList | getChildNodesByTagName(final Element element, final String tagName) get Child Nodes By Tag Name final List<Element> elements = getChildElementsByTagName(element, tagName); return new NodeList() { @Override public Node item(final int index) { if (index >= elements.size()) { return null; return elements.get(index); ... |
List | getChildNodesWithName(Node node, String name) get Child Nodes With Name return getChildNodesWithName(node, name, null);
|
String | getChildNodeText(Element element, String nodeTagName) Returns the text of the child element identified by nodeTagName. NodeList elements = element.getElementsByTagName(nodeTagName); for (int j = 0; j < elements.getLength(); j++) { Node node = (Node) elements.item(j); NodeList elementsChild = node.getChildNodes(); for (int k = 0; k < elementsChild.getLength(); k++) { Node node2 = (Node) elementsChild.item(k); if (node2.getNodeType() == Node.TEXT_NODE) { return node2.getNodeValue(); ... |
String | getChildNodeText(Node root, String childName) get Child Node Text NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { if (childName.equals(nodeList.item(i).getNodeName())) return nodeList.item(i).getTextContent(); return ""; |
String | getChildNodeTextContent(Node parentNode, String childElementName) get Child Node Text Content Node node = getChildNode(parentNode, childElementName); if (node != null) return node.getTextContent(); return null; |
String | getChildNodeTextContents(Node node, String name) get Child Node Text Contents Node tempNode = getChildNode(node, name); if (tempNode != null) return (tempNode.getTextContent()); else return (null); |
String | getChildNodeValue(Element node, String tagName) get Child Node Value NodeList nodes = node.getElementsByTagName(tagName); if (nodes.getLength() > 0) { return nodes.item(0).getTextContent().trim(); return null; |