Version 0 of A little RSS browser

Updated 2004-06-16 13:41:20

Michael Jacobson (16/04/2004) ~ Using RS's A little XML browser and adding some (very little) code here is a RSS tree browser.

http://mywebpages.comcast.net/jakeforce/RssBrowser.jpg


 # A little RSS Browser
 #  based on Richard Suchenwirth's XML Browser
 package require BWidget
 package require tdom

 proc recurseInsert {w node parent} {
    set name [$node nodeName]
    if {$name=="#text" || $name=="cdata"} {
        set text [$node nodeValue]
        set fill black
        set icon file
    } else {
        set text <$name
        foreach att [$node attributes] {
            catch {append text " $att=\"[$node getAttribute $att]\""}
        }
        append text >
        set fill blue
        set icon folder
    }
    $w insert end $parent $node -text $text -fill $fill -image [Bitmap::get $icon] -helptext $::name
    foreach child [$node childNodes] {recurseInsert $w $child $node}
 }

 Tree .t -yscrollcommand ".y set"
 scrollbar .y -ori vert -command ".t yview"
 pack .y  -side right -fill y
 pack .t -side right -fill both -expand 1

 #package require autoproxy  ;# add if needed for proxy support
 #autoproxy::init            
 proc fetch {url} {
    set res [http::data [set tok [http::geturl $url]]]
    http::cleanup $tok
    return $res
 }

 # add more if desired
 set site {http://mini.net/tcl/rss.xml
           http://slashdot.org/slashdot.rss}

 foreach name $site {
         set xml [fetch $name]
         dom parse  $xml doc
         $doc documentElement root
         after 5 recurseInsert .t $root root
 }