I have the following XML structure
<students>
<student studentnumber="1">
<firstname>Charlie</firstname>
<lastname>Davies</lastname>
<marks>
<first>12</first>
<second>52</second>
<third>98</third>
<forth>32</forth>
</marks>
</student>
<student studentnumber="2">
<firstname>Emily</firstname>
<lastname>Roberts</lastname>
<marks>
<first>55</first>
<second>51</second>
<third>57</third>
<forth>84</forth>
</marks>
</student>
How can I construct the query to get the first name of students who have the first mark over 50? I'm doing this and I can see there is one result which what I expect but it doesn't print out anything.
String expression = "/students/student[marks/first > 50]";
NodeList nodes = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
System.out.println(nodes.getLength());
for (int i = 0; i < nodes.getLength(); ++i) {
System.out.println(nodes.item(i).getFirstChild().getNodeValue());
}
Thanks.