I want to achieve this NodeList typecasting in java Nashorn - NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET)
But I am not able to do such typecasting in Nashorn even for other examples. Like it always give me error when I do (some type) object . When I do as below
NodeList = Java.type("org.w3c.dom.NodeList")
objItem = (NodeList) expr.evaluate(xmldoc, javax.xml.xpath.XPathConstants.NODESET)
where expr is XPath expression and xmldoc is Document doc of Java.
then I get error saying - expected ; but found expr
When I do objItem = new NodeList(expr.evaluate(xmldoc, javax.xml.xpath.XPathConstants.NODESET))
then I get error as com.sun.org.apache.xml.internal.dtm.ref.dtmnodelist@1ffcd2aa is not an object. Please let me know how can I do typecasting in Java Nashorn for the same or similar example. I am not able to find any resources for that other than https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/javascript.html.