Perl objects and HTML elements 
Author Message
 Perl objects and HTML elements

Good morning,

I have a small static site with a lot of tables that I'd like to automate
with a Perl module. Specifically, I'm looking for something that would
make the generation of HTML entities (headings, paras, etc) easier and
more reliable. I would be particularly interested in a module that eases
the creation of nested entities, like tables.

Is there any module now available that would allow code (something) like
the following:

use Ideal::HTML::Module;

sub_tbl1 = new table( ... );
sub_tbl1->insert_row( ... );
sub_tbl1->insert_cell( .. );
# ...

sub_tbl2 = new table( ... );
# ...

super_table = new table( ... );

super_table->insert( sub_tbl1 );
super_table->insert( sub_tbl2 );

print super_table;   # prints super_table and all nested entities..

I'm finding the multitude of HTML modules a bit confusing. I've looked at
the documentation on the CPAN for HTML::Table, HTML::TableLayout,
HTML::AsSubs, HTML::Element and HTML::FormatTable. I suppose I could
download and try them all, but I really would appreciate advice on which
of these (if any) will suit my purpose.

I am looking for a tables-related application right now, but I would like
to locate something sufficiently general that I could use it for other
HTML entity applications in the future (headers, paras, etc) without
having to use a different module.

Thanks!

--

=================================



Sat, 15 Feb 2003 03:00:00 GMT  
 Perl objects and HTML elements

says...

Quote:

>Good morning,

>I have a small static site with a lot of tables that I'd like to
automate
>with a Perl module. Specifically, I'm looking for something that
would
>make the generation of HTML entities (headings, paras, etc) easier
and
>more reliable. I would be particularly interested in a module that
eases
>the creation of nested entities, like tables.

>Is there any module now available that would allow code (something)
like
>the following:

>use Ideal::HTML::Module;

>sub_tbl1 = new table( ... );
>sub_tbl1->insert_row( ... );
>sub_tbl1->insert_cell( .. );
># ...

>sub_tbl2 = new table( ... );
># ...

>super_table = new table( ... );

>super_table->insert( sub_tbl1 );
>super_table->insert( sub_tbl2 );

>print super_table;   # prints super_table and all nested entities..

>I'm finding the multitude of HTML modules a bit confusing. I've
looked at
>the documentation on the CPAN for HTML::Table, HTML::TableLayout,
>HTML::AsSubs, HTML::Element and HTML::FormatTable. I suppose I could
>download and try them all, but I really would appreciate advice on
which
>of these (if any) will suit my purpose.

HTML::Table will cope with your example above.

---------------- Untested code example  -----------------------
#!/usr/local/bin/perl -wT

use strict;

use HTML::Table;

my $sub_tbl1 = new HTML::Table();
$sub_tbl1->addRow("cell 1 content" [, "cell 2 conent", ...]);
$sub_tbl1->addRow("cell 1 content" [, "cell 2 conent", ...]);
# ...

my $sub_tbl2 = new HTML::Table();
# ...

my $super_table = new HTML::Table(2,1);

$super_table->setCell(1,1 $sub_tbl1->getTable );
$super_table->setCell(2,1 $sub_tbl2->getTable );

$super_table->print;

---------------- Untested code example  -----------------------

The module can be found on CPAN or
http://www.chime.ucl.ac.uk/~rmhiajp/htmltable.htm

Quote:
>I am looking for a tables-related application right now, but I would
like
>to locate something sufficiently general that I could use it for
other
>HTML entity applications in the future (headers, paras, etc) without
>having to use a different module.

In this case I would look at the HTML::Element modules and
HTML-Element-Extended-1.08.tar.gz which has a HTML::ElementTable
module which is subclassed from the HTML::Element modules.

All of this can be found on CPAN.



Sat, 15 Feb 2003 03:00:00 GMT  
 Perl objects and HTML elements

Quote:

> I have a small static site with a lot of tables that I'd like to automate
> with a Perl module. Specifically, I'm looking for something that would
> make the generation of HTML entities (headings, paras, etc) easier and
> more reliable. I would be particularly interested in a module that eases
> the creation of nested entities, like tables.

You are talking about HTML _elements_, not _entities_.

If you really want a proper object interface to HTML elements you
probably want to look at HTML::Element.

However you may find CGI simpler for simple stuff.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Sun, 16 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HTML::Element::Table, HTML::Element bug

2. Questions re HTML::Element and HTML::TreeBuilder

3. detect text segment and HTML::Element in HTML::TreeBuilder

4. HTML::Calendar, HTML::Element::Table - DISCUSSION

5. Getting the elements of an object...

6. calling ole objects from the database to the html page using perl

7. HTML::Element::extract_links not grabbing frame sources

8. HTML::Element

9. using HTML::Element optional end tags

10. HTML::Element - traversing content only

11. What is an HTML::Element

12. problem with HTML::Element

 

 
Powered by phpBB® Forum Software