XPATH Query limited number of records.

1
How do I write an XPATH query in Java to only return the first n number of records that meet the rest of the XPATH query?
asked
2 answers
2

From the api docs:

 

retrieveXPathQuery(IContext context, java.lang.String xpathQuery, int amount, int offset, java.util.Map<java.lang.String,java.lang.String> sort)

Retrieves object list based on the given XPath query (synchronously).

 

See community commons for examples or snippet from ExcelReader

 

		HashMap<String, String> sortMap = new HashMap<String, String>();
		sortMap.put(Column.MemberNames.ColNumber.toString(), "ASC");
		List<IMendixObject> columns = Core.retrieveXPathQuery(this.settings.getContext(), "//" + Column.getType() + "[" + Column.MemberNames.Column_Template + "=" + template.getId().toLong() + "]", Integer.MAX_VALUE, 0, sortMap);

 

answered
1

Personally I'm a big fan of the XPath class that comes with Community Commons.

XPath<Question> xpat = XPath.create(context, Question.class);
xpat.addSortingDesc(Question.MemberNames.CreatedAt);
return xpat.limit(100).allMendixObjects();

 

answered