Version 42 of html

Updated 2009-02-03 12:43:33 by CMcC

HTML stands for HyperText Markup Language.


html is also a module in the tcllib library of tcl code. Its purpose is to aid developers in generating HTML programmatically. Related modules are ncgi, javascript, and htmlparse.

Documentation can be found at http://tcllib.sourceforge.net/doc/html.html

See tcllib/html questions.


Many with an interest in HTML will want to know about the HTML widgets page, which discusses widgets that render HTML into a visual representation.


If only parsing of HTML is required, without rendering, htmlparse (a module in tcllib) is a possible solution. Other solutions include tkHTML compiled for use without Tk, and tcltidy.

Some Tclers advertise tDOM's XPath-oriented parser as desirable for HTML work. This seems particularly popular among European brethren. Note Jochen Loewer's report on his eBay Web scraping at the Second European Tcl/Tk Users Meeting ( http://www.tu-harburg.de/skf/tcltk/tclum2001.pdf.gz ).


A posting to comp.lang.tcl contained a really small example - it can be found at http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/4c4639ead0d852f8/818f81c90be142fc

If the task is to 'pull out' some data out of a HTML page, I'm indeed a strong believer in the 'parse the HTML page into a tree and query that tree' approach. For real life problems, I claim that this approach is much simpler and easier to maintain - and for sure, you have to maintain such a thingy, because the layout of HTML pages tend to change frequently - than every regexp approach. Sure, you have to learn another query language - xpath in this case. But if you are really in the web business, there are chances you have to learn xpath anyway.

de


If the task is to generate HTML or XML, try xmlgen, a package within TclXML and found on http://sourceforge.net/projects/tclxml/ .


Can Someone submit a sample example code for using html:: package . I need to know how all functions glue together.I read cgi.tcl based examples. More exactly I am wondering If I need to call html::closetags for closing. That is not the case with cgi.tcl. Because of this lack of info I could not use. I am just new to TCL but appreciate its "power from simplicity" approach. Does html:: really a substitute for cgi.tcl -valli


Some example code from comp.lang.tcl :

> Hi,

> I'm just starting to work with the html generation package of tcllib (ver > 1.2.2). Can anyone point me to some examples of how the tcllib html > generation package is used?

Quick taste,

 (bin) 15 % package require html
 1.1
 (bin) 16 % html::textInput first_name
 <input type="text" name="first_name" value="" size="45">

 (bin) 17 % html::textInputRow "MY LABEL" test_row
 <tr>
        <td>MY LABEL</td>
        <td><input type="text" name="test_row" value="" size="45">
        </td>
 </tr>

 (bin) 24 % set people {John Doe Mary Poppins Jack {B. Nimble}}
 John Doe Mary Poppins Jack {B. Nimble}
 (bin) 25 % html::tableFromList $people
 <TABLE ><tr>
        <td>John</td>
        <td>Doe</td>
 </tr>
 <tr>
        <td>Mary</td>
        <td>Poppins</td>
 </tr>
 <tr>
        <td>Jack</td>
        <td>B. Nimble</td>
 </tr>
 </TABLE>

 similarly there's html::tableFromArray, proc html::checkbox etc...
 Using the html package with tclhttpd templates makes form/page
 generation quite simple;-)

Reference link http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/addc4fd39b2eade3/643858bdf6de4509

RLH 2006-02-20: It probably shouldn't spit out uppercase tags like <TABLE>.


Wub utility for structured HTML tag generation web.

Latest version may be sourced here [L1 ] and perused here [L2 ]

CMcC is the current custodian, but help and improvement is welcome.


See also august html editor, url-encoding, html2text