Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting the result from xpath+using interfaces

 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am importing


package org.xml.sax;
import javax.xml.xpath.*;
what else shall i import??
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic