On Wed, 23 Oct 2002, [ISO-8859-1] Torbjørn Lindahl wrote:

> Hi, my problem:
>
> I am parsing a html page looking for table-tags.
>
> The Treebuilder has a look_down function:
>
> $tree->look_down("_tag","table");#lists all tables in the html
>
> $tree->look_down("_tag","table",
>       "width","170");#lists all tables in the html with width 170
>
> However, how can I list all tables that have no attributes? Ie somehow
> listing tag attributes and checking that the @list == 0?

There is a method of HTML::Element called all_external_attr_names(). You
should be able to check each returned table element, and if
all_external_attr_names() returns an empty list, then there were no
attributes specified for that table.

  @tables = $tree->look_down("_tag","table"); # Get all tables

  foreach $table (@tables) {
    @attrs = $table->all_external_attr_names();
    $attr_count = scalar @attrs;
    print "Found a table with $attr_count attributes specified.\n";

    print "\t$foo\n" while ($foo = shift @attrs);
  }

-- 
Ernest MacDougal Campbell III, MCP+I, MCSE <[EMAIL PROTECTED]>
http://dougal.gunters.org/             http://spam.gunters.org/
  Web Design & Development:  http://www.mentalcollective.com/
       This message is guaranteed to be 100% eror frea!

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to