This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Apparently, you are attempting to cast an object to a type that it does not belong to. I'm not sure which line is causing the exception, since you didn't provide the stack trace or line numbers, but I'm assuming it's the cast to (ListNodeList).
Look, xpath.evaluate will not return an instance of ListNodeList, because you have created that class, so xpath doesn't even know that it exists. It's actually returning a DTMNodeList, which is not a subtype of ListNodeList. So you cannot cast DTMNodeList as a ListNodeList. If you want to convert from one to the other, you will have to create a method that will do the conversion.
To do this, you will need to figure out what the "important" members of DTMNodeList are (the ones that you care about), and extract them from the instance of DTMNodeList and use them to create your ListNodeList. Then you can use the methods you created in your ListNodeList class. (Basically, you wil need to obtain the list of nodes from the DTMNodeList and use it in the constructor of your ListNodeList).
You are casting the result of xpath.evaluate(...) to your own class ListNodeList. You get the error because the method returns an object of type com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList, which is not a ListNodeList.
Indeed, DTMNodeList is not a part of the standard Java API, but that's not the problem.
The method xpath.evaluate(...) doesn't know your class ListNodeList, so how can it ever return an object of type ListNodeList?
You just have to use org.w3c.dom.NodeList and not your own class ListNodeList: