Element non trouvé avec xpath
Voici mon fichier xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <root>
<aaa>
<bbb>
<ccc>
<e nom="fr"></e>
<e nom="en"></e>
</ccc>
</bbb>
<bbb>
<ccc>
<e nom="fr"></e>
<e nom="en"></e>
</ccc>
</bbb>
</aaa>
</root> |
Voici mon code Xpath en java :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
XPath xpa = XPath.newInstance("//bbb");
List<?> lbbb = xpa.selectNodes(root);
Iterator<?> iter = lbbb.iterator() ;
Element noeudCourant = null;
while (iter.hasNext())
{
noeudCourant = (Element) iter.next();
XPath xpa2 = XPath.newInstance("./ccc/e[@nom='fr']");
Element elem = (Element) xpa2.selectSingleNode(noeudCourant);
} |
Ma liste d'element "bbb" est complete mais mon Element elem est null, je ne comprends pas pourquoi.
Merci