I have an XML shown below:
<element type="PRICE_SPECIFIC_SIMPLE_QUERY">
<query>
<and>
<match field="product" value="Bottle"/>
<not>
<match field="status" value="Cancel"/>
</not>
<not>
<match field="material">
<value>GLASS</value>
<value>METAL</value>
</match>
</not>
<greaterThan field="LastDateToPrice" value="2017-12-20"/>
<match field="company" value="MILTON"/>
</and>
</query>
</element>
With XPath = /element[@type='PRICE_SPECIFIC_SIMPLE_QUERY', I want inner XML as String...as shown below:
<query>
<and>
<match field="product" value="Bottle"/>
<not>
<match field="status" value="Cancel"/>
</not>
<not>
<match field="material">
<value>GLASS</value>
<value>METAL</value>
</match>
</not>
<greaterThan field="LastDateToPrice" value="2017-12-20"/>
<match field="company" value="MILTON"/>
</and>
</query>
But with examples available online, I am getting inner values, but not XML. My sample code is shown below:
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
String queryType = "ICE_SPECIFIC_SIMPLE_QUERY";
XPathExpression expr = xpath.compile("/element[@type='" + queryType + "']");
String innerElement = (String) expr.evaluate(doc, XPathConstants.STRING);
Actual Output : GLASS \n METAL