Hi.. I would like to retrieve the locations of Hardees restaurants with the zipcode 19939. The URL is http://www.hardees.com/home/
I saved the HTML Page in my system as "D:/selection.htm" and trying to parse the data. Iam using http parser.But Its not parsing the table data.
The code is like this:
import org.htmlparser.Parser; import org.htmlparser.filters.AndFilter; import org.htmlparser.filters.HasAttributeFilter; import org.htmlparser.filters.TagNameFilter; import org.htmlparser.util.NodeList;
public class HardeesParsing { public static void parseHardeesData()throws Exception { String htmlFileToParse="D:/selection.htm"; try { Parser parser=new Parser(htmlFileToParse); NodeList tableList = parser.parse (new TagNameFilter ("TABLE")); System.out.println(tableList.size()); /*for(int i=0;i<=trlist.size();i++) { String s=trlist.elementAt(i).toPlainTextString(); // System.out.println(s); }*/ } catch(Exception e) { e.printStackTrace(); } } public static void main(String args[])throws Exception { try { parseHardeesData(); } catch (Exception e) { } } }
In the out put ,It is showing the tableList.size() as 0 even there is lot of "Table" elements in that page. Please anybody findout the problem?
Regards, Srinivas
Weird. You're sure there are table elements in D:/selection.htm. Try: NodeClassFilter (org.htmlparser.tags.TableTag.class)
Log in to post a comment.
Hi..
I would like to retrieve the locations of Hardees restaurants with the zipcode 19939.
The URL is http://www.hardees.com/home/
I saved the HTML Page in my system as "D:/selection.htm" and trying to parse the data.
Iam using http parser.But Its not parsing the table data.
The code is like this:
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.util.NodeList;
public class HardeesParsing
{
public static void parseHardeesData()throws Exception
{
String htmlFileToParse="D:/selection.htm";
try
{
Parser parser=new Parser(htmlFileToParse);
NodeList tableList = parser.parse (new TagNameFilter ("TABLE"));
System.out.println(tableList.size());
/*for(int i=0;i<=trlist.size();i++)
{
String s=trlist.elementAt(i).toPlainTextString();
// System.out.println(s);
}*/
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])throws Exception
{
try
{
parseHardeesData();
}
catch (Exception e)
{
}
}
}
In the out put ,It is showing the tableList.size() as 0 even there is lot of "Table" elements in that page.
Please anybody findout the problem?
Regards,
Srinivas
Weird.
You're sure there are table elements in D:/selection.htm.
Try: NodeClassFilter (org.htmlparser.tags.TableTag.class)