Saving the text of named VB.NET controls to XML

How to save the text of named VB.NET controls to an XML file


Protected Sub SaveXML_2()

  Dim settings As New XmlWriterSettings()
  settings.Indent = True

  Dim XmlWrt As XmlWriter = XmlWriter.Create("C:\SaveXML_002.xml", settings)

  With XmlWrt




  End With
End Sub

XML (output)

  <customercontact>Adam Watson</customercontact>

Reading XML Nodes into correspondingly named VB.NET Textboxes

Question : How do I read XML node-values (from an XML file) into correspondingly named VB.NET Textbox controls ?


    Programming Widgets Inc.
    Ben Franklin
    Lead Programmer


Protected Sub Page_Load() Handles Me.Load

    Dim settings As New XmlReaderSettings()
    settings.ConformanceLevel = ConformanceLevel.Fragment
    settings.IgnoreWhitespace = True
    settings.IgnoreComments = True

    Dim XML_Reader As XmlReader = XmlReader.Create(C:\XML\basic-information.xml, settings)


    While XML_Reader.Read()

      If XML_Reader.NodeType = XmlNodeType.Element Then

        Dim NodeName As String = XML_Reader.Name

        Dim NodeValue As String = XML_Reader.Value

        Dim PageControl As RadTextBox = RadMultiPage1.FindControl(NodeName)

        If (Not PageControl Is Nothing) Then
          PageControl.Text = NodeValue
          ' "Control not found" - error message
        End If

      End If

      End While

End Sub