Q:

parsing a html report file

I am trying to extract the text content of a html file generated bu some tool.
I cant use normal sax or dom parser because html is not properly formed.
So i tried using htmlparser http://htmlparser.sourceforge.net/
Now how can i extract the node i required?
I used this following code but it doesnot read node text content.It just  prints tds with its attibute.How can i fetch nodes body?
td colspan="2"
td valign="top" class="titleText"

I want to extract whose body has a number and a % symbol
String inputHTML = readFileAsString(filePath);
Parser parser = new Parser();
parser.setInputHTML(inputHTML);
parser.setEncoding("UTF-8");    
NodeList nl = parser.parse(null);
NodeList tds = nl.extractAllNodesThatMatch(new TagNameFilter("td"),true);

for(int i= 0; i < tds.size(); i++) {
    Node node = tds.elementAt(i);
    System.out.println(node.getText());
}       

A:

If it's HTML, an HTML parsing library like Jsoup can deal with HTML and all of it's likely nastiness.

