ragazzi sto cercando di fare il parsing di una pagina html con jtidy solo che quando vado a compilare il programma mi da questo messaggio:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.w3c.tidy.Tidy.<init>(Tidy.java:135)
at org.w3c.tidy.Parsing.main(Parsing.java:29)
Caused by: java.lang.RuntimeException: Failed to load jtidy.properties
at org.w3c.tidy.Report.readReleaseDate(Report.java:94 )
at org.w3c.tidy.Report.<clinit>(Report.java:85)
... 2 more
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Propertie s.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
at org.w3c.tidy.Report.readReleaseDate(Report.java:91 )
... 3 more
Process completed.
il programma è questo:
import org.w3c.tidy.*;
import java.net.URL;
import java.io.*;
import java.net.MalformedURLException;
import java.io.IOException.*;
import org.w3c.dom.*;
import javax.xml.xpath.*;
public class Parsing {
public static void main(String[] args) {
try{
URL url = new URL("http://www.exchange-rates.org/currentRates/E/USD");
BufferedInputStream page = new BufferedInputStream(url.openStream());
Tidy tidy = new Tidy();
tidy.setQuiet(true);
tidy.setShowWarnings(false);
Document response = tidy.parseDOM(page, null);
XPathFactory factory = XPathFactory.newInstance();
XPath xPath=factory.newXPath();
String pattern = "//body/a";
NodeList nodes = (NodeList)xPath.evaluate(pattern, response, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
System.out.println((String) nodes.item(i).getNodeValue());
}
}catch(XPathExpressionException e) {
}catch(MalformedURLException e){
} catch(IOException e){
}
}
}
non riesco a capire dove sia l'errore.
Grazie

Rispondi quotando