slt à tous
j'ai intéger l'api jdom et jdom4 dans l'IDE eclips j'ai fais comme suis
projet,proprities,buidpath add external jar..
et
window, préférences,buidpath,ClassVariable?NEW et j'indique l'emplacement
et
je copies tous les jar dans le repertoire lib dans la racine du projetMAIS LORS DE L'EXCUTION IL ME DIS
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
at org.dom4j.xpath.DefaultXPath.parse(DefaultXPath.java:358)
at org.dom4j.xpath.DefaultXPath.<init>(DefaultXPath.java:59)
at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164)
at Dom4jSample.main(Dom4jSample.java:18)
voici le code
import java.util.*;
import org.dom4j.Document; import org.dom4j.DocumentHelper;
import org.dom4j.Element;
public class Dom4jSample {
public static void main(String args[]) {
Document document = DocumentHelper.createDocument();
Element root = document.addElement( "root" );
Element author2 = root.addElement( "author" )
.addAttribute( "id", "Toby" ).addAttribute( "location", "Germany" )
.addText( "Tobias Rademacher" );
Element author1 = root.addElement( "author" )
.addAttribute( "id", "James" ).addAttribute( "location", "UK" )
.addText( "James Strachan" );
List results = document.selectNodes("//author[@location = 'UK']");
for ( Iterator iter = results.iterator(); iter.hasNext(); ) {
Element element = (Element) iter.next();
System.out.println(element.valueOf("concat(@id,' : ', .)"));
}
}
}
et m'affiche
class file editor
the source attachment does not contain the source for the file DefaultXPath.class.
you can change the source attachment by clicking change AttachED Source below
comment faire?
Partager