Hi I am having an xpath expression "infoList//groupId" which i am trying to apply on a java bean object using jaxen api . however it is returning empty results.
The following is my class
public class Profile {
public Profile() {
}
private Map<String, Info> infoList = null;
// have getters and setters
}
Info class below
public class ChfInfo {
public ChfInfo(String groupId) {
this.groupId = groupId;
}
private String groupId = null;
// getters and setters.
}
From my main class i invoke the following code
Profile profile = new Profile();
Map<String, Info> map = new HashMap<String, Info>();
map.put("key1", new Info("groupId1"));
map.put("key2", new Info("groupId2"));
profile.setInfoList(map);
XPath xpath = new BaseXPath("infoList//groupId");
List nodesList = xpath.selectNodes(profile);
System.out.println(nodesList);
The system.out.println returns an empty list . currently i am using jaxen library. if you know any libraries , other than apach commons-jxpath, that is capable of apply xpath expression on java object please let me know . if possible we want to use a library that is free from CVE's
JavaBeanXPathinstead ofBaseXPathif you target a Java object?