<html>
<table>
<tr bgcolor="ffffff">
<td>one</td>
<td>two</td>
<td>three</td>
<td>four</td>
</tr>
</table>
</html>
How do I get that code simple look like this: one two three four
So, all <*> need to be removed and all numbers has to be put in one
line. I just cant figure out how to use regexp or regsub, they are so
complicate.
I would do something like this:
package require tdom
set source {<html>
<table>
<tr bgcolor="ffffff">
<td>one</td>
<td>two</td>
<td>three</td>
<td>four</td>
</tr>
</table>
</html>}
set doc [dom parse -html $source]
set root [$doc documentElement]
foreach td [$root selectNodes //td] {
append result "[$td text] "
}
puts $result
but that's probably only me.
This requires a compiled extension. If this is OK with you, grab it
from http://sdf.lonestar.org/~loewerj/tdom.cgi
rolf
set html {<html>
<table>
<tr bgcolor="ffffff">
<td>one</td>
<td>two</td>
<td>three</td>
<td>four</td>
</tr>
</table>
</html>}
# remove all html tags: a '<', followed by characters that are not '>',
# followed by '>'
regsub -all {<[^>]*>} $html {} text_only
set one_line [join [string trim $text_only]]
--
Glenn Jackman
gle...@ncf.ca
you might also consider using tcl.cgi package available at:
http://ats.nist.gov/cgi-bin/cgi.tcl/examples.cgi
i suppose you would like to generate code as simple as possible, so it would
look something like this:
package require cgi
set column [list {one two three ....}]
cgi_body {
cgi_table {
cgi_table_row bgcolor=ffffff {
foreach var $column {cgi_td $var}
}
}
}
please note that you'll get <body> instead of <html>,
but i can't remeber if there are any <html> insertion
procedures in cgi package, anyway, you can always insert it using plain puts
stdout.... :)
hope it helps !
best regards,
Domagoj
dom...@engineer.com
"jani" <ja...@jippii.fi> wrote in message
news:417bc2a4.02040...@posting.google.com...
Domagoj
"Domagoj" <dom...@engineer.com> wrote in message
news:a8q1g5$sdv$1...@bagan.srce.hr...