Classes/RssItem.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class RssItem
{
    [string]$Title
    [string]$Description
    [string]$ID
    [string]$Link
    [Nullable[DateTime]]$PubDate

    RssItem($Title)
    {
        $this.Title = $Title
    }

    Write([System.Xml.XmlWriter]$Writer)
    {
        $Writer.WriteStartElement('item')

        $Writer.WriteStartElement('title')
        $Writer.WriteCData($this.Title)
        $Writer.WriteEndElement()

        if ($this.Description)
        {
            $Writer.WriteStartElement('description')
            $Writer.WriteCData($this.Description)
            $Writer.WriteEndElement()
        }
        if ($this.ID) { $Writer.WriteElementString('guid', $this.ID) }
        if ($this.Link) { $Writer.WriteElementString('link', $this.Link) }
        if ($this.PubDate) { $Writer.WriteElementString('pubDate', $this.PubDate.ToString('ddd, d MMM yyyy HH:mm:ss zzz')) }
        $Writer.WriteEndElement() #item
    }
}