1 package org.jdbc4olap.xmla;
2
3 import org.w3c.dom.Node;
4 import org.w3c.dom.NodeList;
5
6 public class XmlaHelper {
7
8 public NodeList getElementsByTagName(final Node root, final String name) {
9 final XmlaNodeList nodeList = new XmlaNodeList();
10 final String nodeName = root.getNodeName();
11 if (nodeName.equals(name)) {
12 nodeList.add(root);
13 }
14 if (root.hasChildNodes()) {
15 final NodeList rootChildren = root.getChildNodes();
16 for (int i = 0; i < rootChildren.getLength(); i++) {
17 nodeList.addAll(getElementsByTagName(rootChildren.item(i), name));
18 }
19 }
20 return nodeList;
21 }
22
23 public String getTextContent(final Node node) {
24 final Node child = node.getFirstChild();
25 if (child != null && child.getNodeType() == Node.TEXT_NODE) {
26 return child.getNodeValue();
27 }
28 return null;
29 }
30 }