Building a simple XML browser with Glamour

Recently, Laurent Laffont published a nice Pharocasts tutorial for producing a simple XML browser of an RSS feed in Pharo.

The tutorial touches several issues, but I would like to focus on the browser building part. The example browser is built using Morphic, the basic graphical user interface of Pharo. While the code is already succinct, still the part related to creating and parameterizing the browser is not intention revealing.

I created a counter part of the same scenario, only using Glamour, the browsing engine that ships with Moose. The resulting code reveals the structure of the browser and does minimizes the boiler plate code.

To get the browser, you can execute the code below in the latest Moose

xml := HTTPClient httpGet:
'http://www.pharocasts.com/feeds/posts/default'.
document := XMLDOMParser parse: xml.
browser := GLMTabulator new title: 'Glamorous XML Browser'.
browser row: #xml; row: #preview.
browser transmit to: #xml; andShow: [:a |
a tree
display: [:doc | {doc root}];
children: [:node | node elements]].
browser transmit from: #xml; to: #preview; andShow: [:a |
a text
display: [:node | node prettyPrinted ]].
browser openOn: document.

You can watch the demo below or on Vimeo:

Posted by Tudor Girba at 7 March 2011, 4:43 pm with tags moose, glamour, assessment, demo link