private Object bodyXPath(
            final Node node,
            final String xpath,
            final QName returnType) {
        try {
            String xml = node.getBody().toXML();
            ByteArrayInputStream stream =
                    new ByteArrayInputStream(xml.getBytes());
            DocumentBuilderFactory factory =
                    DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document = builder.parse(stream);
            XPathFactory xpf = XPathFactory.newInstance();
            XPath xp = xpf.newXPath();
            xp.setNamespaceContext(new NamespaceContext() {
                Map<String, String> map = new HashMap<String, String>();
                {
                    map.put("bosh", BodyQName.BOSH_NS_URI);
                    map.put("xml", XMLConstants.XML_NS_URI);
                }

                public String getNamespaceURI(String prefix) {
                    return map.get(prefix);
                }

                public String getPrefix(String namespaceURI) {
                    throw new UnsupportedOperationException("Not supported.");
                }

                public Iterator getPrefixes(String namespaceURI) {
                    throw new UnsupportedOperationException("Not supported.");
                }

            });
            return xp.evaluate(xpath, document, returnType);
        } catch (Throwable thr) {
            fail("Could not parse body to DOM document: " + thr.getMessage());
        }
        return null;
    }