只需尝试获取具有适当路径表达式的子节点列表,然后检查该列表中是否存在重复项即可:
XPathexpression xPathexpression = xPath.compile("//parentNode/*"); NodeList children = (NodeList) xPathexpression.evaluate(config, XPathConstants.NODESET); for (int i = 0; i < children.getLength(); i++) { // maintain hashset of clients here and check if element is already there }


