NodeList nl = null;
if (source instanceof org.w3c.dom.Node) {
nl = (NodeList) exprFrom.evaluate(source, XPathConstants.NODESET);
} else if (source instanceof String) {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
//quirky: create a temporary element, use its nodelist
Element temp = doc.createElementNS(null, "temp");
temp.appendChild(doc.createTextNode((String) source));
nl = temp.getChildNodes();
} else if (source == null) {