Skip to content Skip to sidebar Skip to footer

How Parse Lu, Li Tags With Jsoup?

I know, there are a lot of questions on this, but no answer helped me. Trying to parse football news from one famous ukrainian portal and put to my listview. I parsed 'news-feed'

Solution 1:

Use

Elements elements = document.select("article.news-feed");

Instead of

Elements elements = document.select(".news-feed");

EDIT: comparing my code to yours, I see good differences, firstly and I think more important, you accumulate the read values in a HashMap, I in a StringBuffer. Then I connect and go this way:

try {

doc = Jsoup.connect("http://football.ua/england.html").userAgent("yourPersonalizedUA").timeout(0).ignoreHttpErrors(true).get();
topicList = doc.select("article.news-feed");

for (Element topic : topicList) {
    myString += topic.html();
}} catch (IOException e) { System.out.println("io - "+e); }

buffer.append(myString);

Then, if everything worked

return buffer.toString();

Presuming you've already stated at the beggining:

private Document doc;
privateString myString;
private StringBuffer buffer;
private Elements topicList;

Not shure if this helps, maybe can lead into a new perspective. Have you succeeded parsing another page with your code?

Post a Comment for "How Parse Lu, Li Tags With Jsoup?"