I have a XML object and Im converting into Doc and trying to fetch one of the tag using Xpath, it returns blank. Please find the code.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <ns:BB_SDF_Response
        xmlns:ns="<url>">
        <ns:BBServiceResponse
            xmlns="<url>">
            <ns1:BBHeader
                xmlns:ns1="<url>">
                <ns1:rsHeader>
                    <ns1:status>
                        <ns1:overallStatus>E</ns1:overallStatus>
                        <ns1:bbMessages>
                            <ns1:formattedMessage>Location does not exist</ns1:formattedMessage>
                        </ns1:bbMessages>
                    </ns1:status>
                </ns1:rsHeader>
            </ns1:BBHeader>
        </ns:BBServiceResponse>
    </ns:BB_SDF_Response>
</soapenv:Body>
</soapenv:Envelope>
My Java code is
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
                        dbf.setNamespaceAware(true); 
DocumentBuilder docBuilder = dbf.newDocumentBuilder(); 
org.w3c.dom.Document doc = docBuilder.parse(new InputSource(new StringReader(soapResponse)));
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();  
logger.info(xpath.evaluate("/Envelope/Body/BB_SDF_Response/BBServiceResponse/BBHeader/rsHeader/status/bbMessages/formattedMessage/",doc, XPathConstants.STRING));
I want to fetch formattedMessage tag value.
 
    