I try to parse xml which look like
<EvaluateHandRequest xmlns="http://www.aaa.com/aaa/schemas">
<card>
<suit>HEARTS</suit>
<face>TEN</face>
</card>
<card>
<suit>SPADES</suit>
<face>KING</face>
</card>
<card>
<suit>HEARTS</suit>
<face>KING</face>
</card>
<card>
<suit>DIAMONDS</suit>
<face>TEN</face>
</card>
<card>
<suit>CLUBS</suit>
<face>TEN</face>
</card>
</EvaluateHandRequest>
And to do it i use XPathExpression, but i can't pull the result.
SAXBuilder jdomBuilder = new SAXBuilder();
Document jdomDocument = jdomBuilder.build(xmlSource);
Element element = jdomDocument.getRootElement();
XPathFactory xFactory = XPathFactory.instance();
XPathExpression xExpression = xFactory.compile("/*/*");
List<Element> list = xExpression.evaluate(element);
System.out.println(list.size() + " " + list.get(0).getName());//5 card
for (Element element2 : list) {
System.out.println(element2.getValue()); //proper result
}
If i use /*/*
expression during compile i get the all cards and them values, where the card
are in the top of hierachy.
But when i use /*/card
i don't get any element from there.
And i can't pull any result if i write any name of any node in expression at all.
What the problem i have ?