954,132 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HTML parsing

Hello,
I'm new to HTML parsing and I need some help.I want to parse a HTML file , and I have the Java classes in place but I need an advise on how to code a piece of logic in my callback function.

I need to parse through the file until I encounter the second table in the file and then display the contents of that particular table.

I'll be grateful if I can get help on this.

Thanks in advance..


Also I am getting a java.net.UnknownHostException: error when I enter any URL in my code. How can I solve that ?

crestaldin
Light Poster
30 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

Hello, I'm new to HTML parsing and I need some help.I want to parse a HTML file , and I have the Java classes in place but I need an advise on how to code a piece of logic in my callback function.

I need to parse through the file until I encounter the second table in the file and then display the contents of that particular table.

I'll be grateful if I can get help on this.

Thanks in advance..


That's pretty simple. Set up a count. So it counts the number of times a <table border="1"> is found. Check out the string api for the 'find' function.

Once it finds the second occurence push all the data into storage untill it gets to the </table> . For example, I'd push each line into an arraylist.Also I am getting a java.net.UnknownHostException: error when I enter any URL in my code. How can I solve that ?
I guess you're trying to use the java.net package to access url's from your program. Read the documentation carefully. It's most likely to be a simple error. Are you putting ahttp:// before each web address? Post some code if you like.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Thanks a lot iamthwee!

crestaldin
Light Poster
30 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

thanks i was also looking for exactly the same to help me with a xml parser project.

b2daj
Newbie Poster
8 posts since Aug 2006
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You