0

I hope you can point me in a right direction, Im making a Android app that gets content of a website, At the moment my app loads dat webpage in a webview, but the page is to wide for almost every screen, so i had another idea:

webcontent(html) -> get contents of table with android -> make a listview -> when sliding right you get another day.

the webcontent is a timetable for school, a example is this one http://intranet.staring.nl/toepassingen/rooster/lochem/2W2/2012102920121104/2W01532.htm what i want is that every day comes in a listview and that a user can swap right or left to change the day there seeing.

Now im getting already stuck on making the listview from the html source, can somebody help me with this?

NewUser
  • 3,729
  • 10
  • 57
  • 79
WHDeveloper
  • 333
  • 2
  • 14
  • You probably have two options. If you don't control the html, they can break easily. use an xml parser if the html is perfect, or screen scrape (string manipulation like substring, indexOf etc.) – Shellum Oct 31 '12 at 16:53
  • With "perfect html" you mean that everything is opened and closed like "" or something else? Every page my app needs to read is like the one in the question, are pages like that "perfect"? – WHDeveloper Oct 31 '12 at 17:34
  • perfect as in correctly formed so an xml parser doesn't choke. Depending on the use, (if you or a small group are the only users), screen scraping html with strings can work great and can be easy depending on how much info you want and if there are unique delimiters. – Shellum Oct 31 '12 at 18:01
  • in the html code i gave is nothing unique, everything is exactly the same but just on another place. But thanks for you help:) – WHDeveloper Oct 31 '12 at 21:59

1 Answers1

1

You should access those data using a webservice...

Because otherwise you'll need to download a LOT of useless HTML code + parse it...

But IF this is the way you want to go, or you have no control over that website, you could read the file and simply parse it using regular expressions I guess.

Here are some tools I found:

Parsing HTML in Java?

Community
  • 1
  • 1
shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • I dont have the control over the website, so the webservice option is not availeble for me, for the regex, isnt it to difficult to read the html with regex? – WHDeveloper Oct 31 '12 at 17:30
  • Well you'll have to parse the HTML in a way. I'm not aware of Java wrappers to load HTML into objects, but I guess they are. – shkschneider Oct 31 '12 at 17:35
  • "You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML." thats what i read from so i think that regex is not the best option for parsing the html – WHDeveloper Oct 31 '12 at 17:38
  • @WHDeveloper Do you know any good tool to parse HTML in Java? – shkschneider Oct 31 '12 at 17:40
  • No I don't, but im searching for a good way for my application so i can create a listview from web content – WHDeveloper Oct 31 '12 at 17:43
  • I proposed some tools known to process HTML from Java, but I never used them, sorry. – shkschneider Oct 31 '12 at 17:45
  • that JSoup is what I'm searching i think:) – WHDeveloper Oct 31 '12 at 17:50