-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Solution:
I just put the jaxen-1.1-beta-7.jar in the library-path. Then it worked.
I'm wondering why this has to be done because the needed classes/methods
should already be included in the dom4j-1.6.1.jar.

Any comments?
Peter

Peter Emmerling wrote:
> Hi,
> 
> I'm dealing with servlets, tomcat5.028, java1.5.0 and dom4j1.6.1.
> I would like to process a xml-file by means of a xml_utility-class.
> I always get an Invalid XPath Expression-Exception with the code you can
> see below, but when I'm using an Iterator like:
>    Element root = doc.getRootElement();
>    for (Iterator i2 = root.elementIterator("id");i2.hasNext();){
>       Element id =(Element) i2.next();
>       x=id.attributeValue("nr");
>    }
> 
> it works. As soon as I try to use
> List ids =doc.selectNodes("//@nr");
> (see all the code below)I get an Exception (invalid XPath Expression),
> no matter what expression it is.
> 
> Is there a solution?
> Thanks, Peter
> 
> 
> here is a simmple xml-File:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <language>
>   <id nr="2">
>     <dt>hallo</dt>
>     <en>hellochen</en>
>   </id>
> </language>
> 
> here is the simple java XML_Util-class:
> 
> import java.io.BufferedReader;
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
> import java.io.FileReader;
> import java.io.IOException;
> import java.io.UnsupportedEncodingException;
> import java.util.List;
> 
> import org.dom4j.Document;
> import org.dom4j.DocumentHelper;
> import org.dom4j.Element;
> import org.dom4j.io.OutputFormat;
> import org.dom4j.io.SAXReader;
> import org.dom4j.io.XMLWriter;
> 
> public class XML_Utils {
>       public static String xml_string(String l, String nr) {
>               Document doc=null;
>               String cur;
>               cur="";
>               SAXReader xmlReader = new SAXReader();
>               try {
> 
>                       File f=new
> File(System.getProperty("catalina.base").toString()+"/webapps/Arbeiten/xmls/lang2.xml");
>                       doc = xmlReader.read(f);
>                       String x="no";
>                       List ids =doc.selectNodes("//@nr");
>                       return x;
>               } catch (Exception e) {
>                       return e.getMessage();
>               }
>       }
> 
>    }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDJq634JlqBAoRt3sRAnQbAJ9Tr3ra8x+Qqfj9FZpHtu5juKxZBQCeLi/z
BqTiVueQ3gdgvYg8h9FYqAE=
=DXPC
-----END PGP SIGNATURE-----


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to