Classes/Outline.ps1

class Outline
{
    [string]$Text
    [string]$Type
    [hashtable]$Attributes
    [System.Collections.Generic.List[Outline]]$ChildNodes

    Outline($Text)
    {
        $this.Text = $Text
        $this.Attributes = @{}
        $this.ChildNodes = New-Object -TypeName 'System.Collections.Generic.List[Outline]'
    }

    Write([System.Xml.XmlWriter]$Writer)
    {
        $Writer.WriteStartElement('outline');
        $Writer.WriteAttributeString('text', $this.Text)
        if ($this.Type) { $Writer.WriteAttributeString('type', $this.Type) }
        $this.Attributes.Keys | ForEach-Object { $Writer.WriteAttributeString($_, $this.Attributes[$_]) }
        $this.ChildNodes | ForEach-Object { $_.Write($Writer) }
        $Writer.WriteEndElement() # outline
    }
}