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 ?

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

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 a http:// before each web address? Post some code if you like.

Thanks a lot iamthwee!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.