To be clear, my xml and its XPath are dynamic, anything may come, so no hard coded values to parse XML value from XPath. Here is my XML and XPath constructed.
String xml = "<soapenv:Envelope xmlns:com=\"http://com\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body><com:addition><com:a>1</com:a><com:b>1</com:b></com:addition></soapenv:Body></soapenv:Envelope>";
Document doc = UtilityFunction.createXMLDocument(xml);
System.out.println("Value "+XPathFactory.newInstance().newXPath().compile("//soapenv:Envelope[1]/soapenv:Body[1]/com:addition[1]/com:a[1]").evaluate(doc).toString());
Empty is getting printed. How can I use namespace to get XML value from xpath. How to enable namespace in compilation.