Re: reversing html
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: Fri, 28 Sep 2007 20:18:36 -0700
On Sep 29, 7:18 am, Aric Bills <aric.bi...@xxxxxxxxx> wrote:
On Sep 28, 3:17 pm, Aric Bills <aric.bi...@xxxxxxxxx> wrote:
Here's a solution off the top of my head. It can probably be made
more elegant, but it will do the job.
package require tdom
set file [open $inputfile r]
# fconfigure $file as necessary
set doc [dom parse -html -channel $file]
close $file
foreach row [$doc selectNodes {//tr}] {
set children [$row childNodes]
foreach child $children {
$row removeChild $child
}
foreach child [lreverse $children] {
$row appendChild $child
}
}
set file [open $outputfile w]
# fconfigure $file as necessary
puts $file [$doc asHTML]
close $file
Forgot to mention that this requires Tcl 8.5, or else that you write
your own [lreverse] command.
That's not too hard though:
proc lreverse {thelist} {
set ret {}
set llen [llength $thelist]
for {set x $llen} {[incr x -1] >= 0} {} {
lappend ret [lindex $thelist $x]
}
return $ret
}
.
- References:
- reversing html
- From: yahalom
- Re: reversing html
- From: Aric Bills
- Re: reversing html
- From: Aric Bills
- reversing html
- Prev by Date: Re: 8.5 docs: no "in" description
- Next by Date: Re: 8.5 docs: no "in" description
- Previous by thread: Re: reversing html
- Next by thread: Converting ANI to DNIS on a cisco router
- Index(es):