Bonjour,
Je voudrais extraire des elements d'un objet Document xml, j'ai vu plusieurs exemples. Cependant, j'ai beau essayé ces exemples j'ai toujours une exception :
ce qui est en rouge est ma classe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 java.lang.ClassCastException: org.jdom.Element com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:115) com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:97) com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:178) fr.cvf.stdelia.servletfilter.fileRights.FileRightsGenerator.completeFileWithNo(FileRightsGenerator.java:252)
voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 try { XPathFactory fabrique = XPathFactory.newInstance(); javax.xml.xpath.XPath xpath = fabrique.newXPath(); XPathExpression exp = xpath.compile("//role"); NodeList results = (NodeList) exp.evaluate(document, XPathConstants.NODESET); } catch (XPathExpressionException e) { LOGGER.error(e); // TODO À compléter }
Merci de bien vouloir m'aider.
Partager