Today's Smalltalk Daily looks at how to create an XML document using a SAX driver - the example being an RSS feed. If you're looking for a particular topic, you can find it with the Media Search application on our site.
Here's the script I used to create the RSS Feed:
"Using a SAX Driver"
stream := ('rss1.xml' asFilename withEncoding: #'UTF-8') writeStream.
writer := RSS20_SAXWriter new output: stream.
"start the document"
writer prolog.
writer startRSS.
writer startChannel.
writer title: 'My RSS Feed'.
writer link: 'http://www.somesite.com'.
writer description: 'My RSS Feed'.
"Now write an item"
writer startItem.
writer title: 'Test Item'.
writer link: 'http://www.somesite.com/item1'.
writer description: 'test item1'.
writer pubDate: Timestamp now.
writer endItem.
"end the document"
writer endChannel.
writer endRSS.
stream close.
To watch, click on the viewer below:
If you have trouble viewing that directly, you can click here to download the video directly
You can also watch it on YouTube:
Technorati Tags:
smalltalk, rss, sax, xml