« Flex Time | Main | The Silly Season »

June 29, 2005

Monad and RSS, Part 3

First, a couple of improvements in the array handling of my previous get-feeds.msh script.

The MSH language has a -contains operator, which will tell you if an array contains an element. So instead of the clunky:

$seen = $false
for ($i = 0; $i -lt $seenlist.length; ++$i) {
    if ($seenlist[$i] -eq $_.pubDate) {
        $seen = $true
if (!$seen) {

you can just say:

if (!($seenlist -contains $_.pubDate)) {

Also, to extend an array that might be empty, instead of:

if ($seenlist -eq $null) {
    $seenlist = [array]$_.pubDate
} else {
    $seenlist += $_.pubDate

You can do:

$seenlist += @($_.pubDate)

OK, now let's talk about output formatting. In Monad the formatting of objects is controlled by files that end in ".format.mshxml". If you look in your Monad directory (you DO have a Monad directory, right?) then you will see several files like this. You can easily add your own.

If you look inside, you will see a bunch of views for different types. If we create a new file rss.format.mshxml (and add it to filelist.format.mshxml, minor point), then we can set it up like this:


Now instead of typing

write-host $rssdata.rss.channel.title

You can type:


It will pick up the format.mshxml information for System.Xml.XmlDocument and display only the title (and a header that says "Title").

But surely you don't want to display ANY XmlDocument this way? And what about the items? And maybe we want to use this to handle different RSS formats...all good ideas, but we'll save them for later. I'm off for 5 days of vacation. Don't bother coming by to boost our television, the kids and aunts will still be in the house.

Posted by AdamBa at June 29, 2005 11:33 PM

Trackback Pings

TrackBack URL for this entry: