• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Getting the result from xpath+using interfaces

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic