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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s