// Create an object to resolve namespace prefixes.
// XPath namespaces are resolved from the input context node's document element
// if it is a root node, or else the current context node (for lack of a better
// resolution space, given the simplicity of this sample code).
PrefixResolverDefault prefixResolver =
new PrefixResolverDefault((namespaceNode.getNodeType()
== Node.DOCUMENT_NODE)
? ((Document) namespaceNode)
.getDocumentElement()
: namespaceNode);
String str = getStrFromNode(xpathnode);