aspose file tools*
The moose likes Beginning Java and the fly likes Getting the result from xpath+using interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting the result from xpath+using interfaces" Watch "Getting the result from xpath+using interfaces" New topic
Author

Getting the result from xpath+using interfaces

Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
Dear All,

I am trying to get the results from an xpath excpression but the problem is i do not know how to get it in a nodeset , nodelist or even a normal list
the only thing that is working is a String , so i get only one output

String projectStatements = (String) xpath.evaluate(stmtExpr, inputSource,
XPathConstants.STRING );

when i try writing NodeSet/Nodelist instead of String i get an error ,,what shall i do??



I need to loop on all results of the xpath to print them.

Thanks

Maha Aburahma

[ July 17, 2006: Message edited by: Maha Hassan ]
[ July 17, 2006: Message edited by: Maha Hassan ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You need to import the classes you are using properly. Let me move this post to Java in General (Beginner), which would be a more appropriate place for it.
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
i am importing


package org.xml.sax;
import javax.xml.xpath.*;
what else shall i import??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The messages tell you that. You need to import the NodeSet and XpathConstants classes from whatever packages they are in.

I don't see them in the API documentation for Java 1.4, which is what I have on my computer here. Perhaps they are in Java 5, which I don't have. Check your Java 5 documentation. And if that is where they are, make sure you are using a Java 5 compiler.
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
i found that nodelist(instead of nodeset since nodeset is not in java 1.5) is an interface at java 1.5 but i am wondering how to use it ??
[ July 17, 2006: Message edited by: Maha Hassan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the result from xpath+using interfaces