[Htmlparser-user] Extract Data from Table Row Question.
Brought to you by:
derrickoswald
|
From: andrew d. <and...@ho...> - 2006-09-06 11:01:25
|
Hello All and Thanks for looking at my Question.
I am still new to Java and HtmlParser I have se series of Web pages stored
offline that i need to process, that are made up of tables, i can find the
tables tag, and then all Table Rows, but the next bit is stumping me, I.e
how do i read the TD values or how to check invidual tags to see if there is
more processing to do (see Source Example below)
Many Thanks for Any help.
public static void process(NodeList listx)
{
// Scan for "tr" tags and Extract info
NodeList TableList = listx.extractAllNodesThatMatch(new
TagNameFilter("tr"));
for (int x = 0; x < xx.size(); x++)
{
// Process Nodes or Tags this is what is stamping me
1. How do i read all TD from nodes with say format <TD class="listi"> etc
and get their value
2. Or How do i get invidural Tags for futher processing
}
}
public static void main(String[] args) {
try {
parser = new Parser("c:\\HtmlTest0002.htm");
// Look for Table Tag
list = parser.parse (new TagNameFilter("table"));
for (int x = 0; x < list.size(); x++)
{
// Is it the right Table
if (list.elementAt(x).toString().contains("listme"))
{
// Get all Children and process
process(list.elementAt(x).getChildren());
}
}
} catch (ParserException ex) {
ex.printStackTrace();
}
}
}
|