Object result = null;
if (src instanceof String)
{
Document doc = DocumentHelper.parseText((String) src);
XPath xpath = doc.createXPath(expression);
if (namespaces != null)
{
xpath.setNamespaceURIs(namespaces);
}
// This is the way we always did it before, so keep doing it that way
// as xpath.evaluate() will return non-string results (like Doubles)
// for some scenarios.
if (outputType == null && singleResult)
{
return xpath.valueOf(doc);
}
// TODO handle non-list cases, see
//http://www.dom4j.org/apidocs/org/dom4j/XPath.html#evaluate(java.lang.Object)
Object obj = xpath.evaluate(doc);
if (obj instanceof List)
{
for (int i = 0; i < ((List<?>) obj).size(); i++)
{
final Node node = (Node) ((List<?>) obj).get(i);