Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Html table

158 views
Skip to first unread message

jani

unread,
Apr 6, 2002, 11:53:34 AM4/6/02
to
Hi,

<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.

Rolf Ade

unread,
Apr 6, 2002, 3:05:27 PM4/6/02
to
In article <417bc2a4.02040...@posting.google.com>,

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

Glenn Jackman

unread,
Apr 6, 2002, 5:27:56 PM4/6/02
to
jani (ja...@jippii.fi) writes:
[...]
> 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.


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

Domagoj

unread,
Apr 7, 2002, 2:04:09 PM4/7/02
to
hi

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

unread,
Apr 7, 2002, 2:06:28 PM4/7/02
to
sorry, i've misread your post in a hurry :)
i see you need an oposite thing actually :)))
Glen post will do in that case ....

Domagoj


"Domagoj" <dom...@engineer.com> wrote in message
news:a8q1g5$sdv$1...@bagan.srce.hr...

0 new messages