foobar. . .",
then the application can request the "name" element like so:
ConfigReader config = new ConfigReader(...);
String name = config.getParameter("app-config.params.name");
Note that this method is fairly limited in its capabilities. It does not
support multiple paths through the document that match the given element.
Instead, it simply returns the value of first matching element that it
finds in the document. It also only supports element values that can be
converted directly to String values.
String paramVal = null;
Element currNode = mXMLConfig.getDocumentElement();
StringTokenizer tokenizer = new StringTokenizer(paramSpec, ".");
boolean firstOne = true;
while (tokenizer.hasMoreTokens()) {
String elem = tokenizer.nextToken();
if (firstOne) {
firstOne = false;
if (currNode.getNodeName().equals(elem)) {
continue;
}
else {
break;
}
}
NodeList nodes = currNode.getElementsByTagName(elem);
currNode = (Element)nodes.item(0);
}
if (currNode != null) {
paramVal = currNode.getChildNodes().item(0).getNodeValue();
}
return paramVal;