Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help in Parsing through an HTML page

Status
Not open for further replies.

Kirad

Programmer
Jul 13, 2001
5
CA
I'm able to read in an HTML page but having trouble in deciding how to parse through a page of HTML tags to get the info. I need.
This is the code I used to read in the HTML PAGE. All I need from this page is the countries and their currencies to put them in a table format.

import java.net.*;
import java.io.*;

public class URLReaderExample
{
public static void main(String[] args)throws Exception
{ String input;
URL carleton = new URL(" BufferedReader in = new BufferedReader(new InputStreamReader(carleton.openStream()));

while((input=in.readLine()) != null)
System.out.println(input);

in.close();
}
}
 
I have extended the program of yours. I am not sure what table format your are refering to (JTable?) but it should be easy to continue from here. I am unable to access the url too..

import java.net.*;
import java.io.*;

public class URLReaderExample
{
public static void main(String[] args)throws Exception
{
String input;
URL carleton = new URL(" BufferedReader in = new BufferedReader(new InputStreamReader(carleton.openStream()));
while((input=in.readLine()) != null)
{
input = input.trim();
if (input.indexOf(&quot;<table&quot;) != -1)
{
System.out.println(input);
while((input=in.readLine()) != null)
{
input = input.trim();
if (!input.equalsIgnoreCase(&quot;</table>&quot;))
System.out.println(input);
else
{
System.out.println(input);
break;
}
}
}
}
in.close();
}
}

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top