Thanks Guitte,
Plz tell me how I read my html file with this API.
I am reading the HTML file Like That-
String filename = "c:\text.html";
BufferedReader input = null;
input = new BufferedReader( new FileReader(filename) );
String line = null;
while (( line = input.readLine()) != null)
{
String str="";
int index=0;
while(index<line.length())
{
char c = line.charAt(index++);
String strchar = String.valueOf(c);
}
}
How we use your API with this code.
If another way to read this then tell me.>
Depends on which one of the APIs you use--the link I gave refers to a collection of different HTML parsers. The code you posted looks like a first step to a parser of your own. So you can a) use an external API and feed it what it wants (File, URL, String ... depends) or b) proceed with your code and implement a minimum of a parser in order to achieve your aim.
What are you trying to achieve with your program?
If you use JTidy (http://jtidy.sourceforge.net/) for instance, you can have it parse HTML delivered by an InputStream, e.g.:
Document doc = new Tidy().parseDom(url.openStream(),null);
This doc can be transformed into Formatting Objects (FO) style and finally into a PDF (http://xmlgraphics.apache.org/fop/).
The raw process is as follows:
(HTML) -- JTidy --> (XML-DOM) -- XSLT --> (XML-FO) -- FOP --> (PDF)
For the details, there's too much technical stuff about how to use the respective tools/APIs for this place. You should look for a more specialized community place. Here's a link to give you a start:
http://wiki.apache.org/xmlgraphics-fop/HowTo/HtmlToPdf