0

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

4
  • Shouldn't you use JavaBeanXPath instead of BaseXPath if you target a Java object? Commented Mar 25 at 12:53
  • i tried using JavaBeanXPath but didnt work Commented Mar 25 at 13:11
  • Is there any documentation of the mapping of Java beans to XPath for the Jaxen library? Does it deal with maps at all? Commented Mar 25 at 14:02
  • unfortunately i cant see any documentation for using jaxen library Commented Mar 25 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.