I am trying to parse xml string and I am getting java.lang.String cannot be cast to org.w3c.dom.Node
error.
This is the code I am using:
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xPath = xPathFactory.newXPath();
String expression = "//Home/ListOfCustomers";
XPathExpression xPathExpression = xPath.compile(expression);
Object nl = xPathExpression.evaluate(xmlResp);
This is how the XML string is constructed:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Home>
<ListOfCustomers type="Regular" count="939">
<Customer>
<CustName>xyz</CustName>
</Customer>
<Customer>
<CustName>abc</CustName>
</Customer>
<Customer>
<CustName>def</CustName>
</Customer>
</ListOfCustomers>
</Home>
What am I missing here?