Menu

Parsing table data..got a problem

Help
2007-11-14
2013-04-27
  • DivakaraSrinivas

    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

     
    • Derrick Oswald

      Derrick Oswald - 2007-11-14

      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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.