Node.selectNodes Method Sometimes Returns List<Object> Instead of List<Node> #179
Description
Description:
I encountered an issue when using the dom4j selectNodes(String xpath) method. According to the documentation and method signature, this method should return List, but in practice, it sometimes returns List. This leads to type casting issues when processing the returned list.
List<Node> nodes = node.selectNodes(xpath);
if (CollUtil.isNotEmpty(nodes)) {
Node node1 = nodes.get(0);
// Assuming nodes.get(0) always returns a Node type, but in reality, it might return a String or other types
}
Expected Behavior:
The selectNodes method should always return a List, with each item in the list being of type Node.
Actual Behavior:
In some cases, the selectNodes method returns a list where the elements are not of Node type, potentially being String or other types, leading to type casting errors when using expressions like nodes.get(0).
Request:
Please confirm if this is a bug and provide a plan for its resolution, or clearly specify in the documentation the possible return types of the method along with appropriate handling suggestions.