if 0 {phk 2003-08-18 Let's assume your application is generating html pages.
tdom can help in a nice way to test the output.
Let's get all options from a html select tag:}
package require tdom package require http # get the html page set token [http::geturl http://aspn.activestate.com/ASPN/Cookbook/Tcl/] set data [http::data $token] # parse the html set doc [dom parse -html $data] set root [$doc documentElement] # get all option nodes set optionList [$root selectNodes {//select/option}] set result {} # loop through all the options foreach option $optionList { set text [[$option nextSibling] nodeValue] set value [$option getAttribute value] lappend result [list $text $value] } puts $result
if 0 {which shows all the options
{{this section} Subsection} {{all ASPN} ASPN} {Products Products} {Recipes Recipes} {News NewsFeeds} {Modules Modules} {{Mailing Lists} Archive} {{The Perl Journal} TPJ} {Reference Reference} from this html code fragment ... <select name="type"> <option value="Subsection">this section</option> <option value="ASPN">all ASPN</option> <option value="Products">Products</option> <option value="Recipes">Recipes</option> <option value="NewsFeeds">News</option> <option value="Modules">Modules</option> <option value="Archive">Mailing Lists</option> <option value="TPJ">The Perl Journal</option> <option value="Reference">Reference</option> </select> ...
The result can be used in a tcltest proc or however.
of course can code can be shorter, but I think it explains more this way.
This is my first wiki contribution, any feedback is appreciated}