2011-03-25 7 views

Répondre

1

Utilisez Jsoup. Il prend en charge la sélection des éléments en utilisant CSS selectors. Commencez par this cookbook introduction.

Coup d'envoi exemple:

Document document = Jsoup.parse(new File("/foo.html"), "UTF-8"); 
Elements links = document.select("a"); 
for (Element link : links) { 
    String url = link.absUrl("href"); 
    // ... 
} 
+0

i've tried like this but still getting ERORR
org.jsoup.nodes.Document document; \t \t try { \t \t \t document = Jsoup.parse(new File( \t \t \t \t \t "E:/Spike/Sixthsense/javahtmlparsing/src/test.html"), \t \t \t \t \t "UTF-8"); \t \t \t Elements links = document.select("a"); \t \t \t for (org.jsoup.nodes.Element link : links) { \t \t \t \t String url = link.absUrl("href"); \t \t \t \t Toast.makeText(this, "URL " + url, Toast.LENGTH_LONG).show(); \t \t \t } \t \t } catch (IOException e) { \t \t \t Toast.makeText(this, "Error " + e.getMessage(), Toast.LENGTH_LONG) \t \t \t \t \t .show(); \t \t }
Android

+0

Lire le message d'exception. – BalusC