1

I have a question:

I have a link: http://wap.nastabuss.se/its4wap/QueryForm.aspx?hpl=Teleborg+C+(V%C3%A4xj%C3%B6) and I wanna take only some specific data from this link and to show in textview in Android.

Is this possible in Android, I mean is there any chance by parsing or I don't know, you can suggest me guys.

For example I just want to take this column Nästa tur (min) from that site.

Regards

2
  • Duplicate: stackoverflow.com/q/7114282/21727 Commented Oct 22, 2011 at 23:35
  • Welcome to stackoverflow! If you find an answer helpful, you can vote it up! If you feel that someone has adequately answered your question, click the check-mark next to the answer to accept it. Commented Oct 22, 2011 at 23:40

2 Answers 2

2

JSoup is pretty nice and getting popular. Here's how you could just parse the whole table:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm"); Document doc = Jsoup.parse(url, 3000); Element table = doc.select("table[title=Avgångar:]").first(); Iterator<Element> it = table.select("td").iterator(); //we know the third td element is where we wanna start so we call .next twice it.next(); it.next(); while(it.hasNext()){ // do what ever you want with the td element here //iterate three times to get to the next td you want. checking after the first // one to make sure // we're not at the end of the table. it.next(); if(!it.hasNext()){ break; } it.next(); it.next(); } 
Sign up to request clarification or add additional context in comments.

9 Comments

it says to create a new class JSoup, i checked the official website of JSoup and the file is.jar should i import it in my project as jar or how i can handle this?
Yes, you'll need to add the JSoup jar into you project.
I added the file JSoup.jar in my project in folder src and still it is saying Create a class JSoup, should i need to paste it somewhere else or what the problem??? i have got lots of errror :S
Here's how to import externals jars into an android project: stackoverflow.com/questions/1334802/…
i fixed out the importing stuffs, now there is problem in code i guess.
|
-1

If the parsing seems simple enough and you want you could also use regular expressions to find the correct part of the html. Regular expressions will be useful to know at some point anyway. Using some XML/HTML parsing library is the more flexible way to do it (XMLReader for example).

2 Comments

do u know any specific example about this case??? Seems like difficult to start from zero. I would appreciate it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.