Hi All,

I am using this code to save label information to an XML file after the label is clicked. Modifying this code, I can seem to save the label info correctly, but I am getting stuck on the loading label info back to my from labels when I run the code. I'm not even sure if this is the proper way of doing this. My modified label only contains a new backcolor and text. Near the end of my 'LoadLabels', I am also not sure what to do on the 'With labels'...

*Note that I am referencing buttons in some parts, but this is only for Labels on my form.

Code:
    Private Sub SaveLabels(ByVal container As Form1, ByVal filename As String)

        Dim xmlfile As New Xml.XmlDocument
        Dim decl As XmlDeclaration = xmlfile.CreateXmlDeclaration("1.0", "UTF-8", "yes")
        FilePathToXML = prgPath & "\schedule.xml"

        xmlfile.AppendChild(decl)
        Dim labelsroot As XmlElement = xmlfile.CreateElement("buttoncollection")
        xmlfile.AppendChild(labelsroot)

        For Each lbl As Label In Me.Controls.OfType(Of Label)()

            Dim labelnode As XmlElement = xmlfile.CreateElement("button")
            Dim textattr As XmlAttribute = xmlfile.CreateAttribute("text")
            Dim kolor As XmlAttribute = xmlfile.CreateAttribute("color")

            textattr.Value = lbl.Text
            kolor.Value = lbl.BackColor.ToArgb

            With labelnode.Attributes
                .Append(textattr)
                .Append(kolor)
            End With

            labelsroot.AppendChild(labelnode)
        Next

        xmlfile.Save(FilePathToXML)
    End Sub


    Private Sub LoadLabels(ByVal container As Form1, ByVal filename As String)

        FilePathToXML = prgPath & "\schedule.xml"

        Dim xmlfile As New XmlDocument

        Try
            xmlfile.Load(FilePathToXML)
        Catch ex As IOException
            MsgBox("Error Loading XML File or file does not exist!" & ex.Message, vbExclamation, "xml not found..")

            Dim xmlfileNew As New Xml.XmlDocument
            Dim decl As XmlDeclaration = xmlfileNew.CreateXmlDeclaration("1.0", "UTF-8", "yes")

            xmlfileNew.AppendChild(decl)
            Dim labelsroot As XmlElement = xmlfileNew.CreateElement("buttoncollection")
            xmlfileNew.AppendChild(labelsroot)
            xmlfileNew.Save(FilePathToXML)
            Exit Sub
        End Try

        Dim buttonsroot As XmlElement = DirectCast(xmlfile.SelectSingleNode("buttoncollection"), XmlElement)

        For Each buttonnode As XmlElement In buttonsroot.ChildNodes.OfType(Of XmlElement)()

            With Labels????
                .Text = buttonnode.Attributes("text").Value
                .ForeColor = Color.Firebrick
                .BackColor = Color.LightGreen
                .TextAlign = ContentAlignment.MiddleCenter
                .Size = Size
                .Font = New Font("Agency FB", 12, FontStyle.Regular)
            End With
        Next

    End Sub