Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:25:14+00:00 2026-06-12T09:25:14+00:00

This is not a question but instead is an example that might be useful

  • 0

This is not a question but instead is an example that might be useful to someone like me who wants to study how the VB.NET XmlDocument node hierarchy works.

The following subroutine recursively walks the XML document tree displaying elements and attributes as encountered…

Private Sub XmlDocumentWalker(XmlNode As XmlNode)

    If TypeOf XmlNode Is XmlComment Then

        MsgBox(XmlNode.Value, MsgBoxStyle.OkOnly, "XML Comment")

        If XmlNode.HasChildNodes Then XmlDocumentWalker(XmlNode.FirstChild)
        If Not IsNothing(XmlNode.NextSibling) Then XmlDocumentWalker(XmlNode.NextSibling)

    ElseIf TypeOf XmlNode Is XmlElement Then

        If XmlNode.HasChildNodes And (TypeOf XmlNode.FirstChild Is XmlText) Then

            MsgBox(XmlNode.Name & "=""" & XmlNode.FirstChild.Value & """", MsgBoxStyle.OkOnly, "XML Element")

        Else

            MsgBox(XmlNode.Name, MsgBoxStyle.OkOnly, "XML Element")

        End If

        If DirectCast(XmlNode, XmlElement).HasAttributes Then
            For Each XmlAttribute As XmlNode In DirectCast(XmlNode, XmlElement).Attributes

                MsgBox(XmlAttribute.Name & "=""" & XmlAttribute.Value & """", MsgBoxStyle.OkOnly, "XML Attribute")

            Next
        End If

        If XmlNode.HasChildNodes And Not (TypeOf XmlNode.FirstChild Is XmlText) Then XmlDocumentWalker(XmlNode.FirstChild)
        If Not IsNothing(XmlNode.NextSibling) Then XmlDocumentWalker(XmlNode.NextSibling)
    End If
End Sub

The following code is provided to illustrate actually loading an XML Document to be walked by the XMLDocumentWalker subroutine:

Private XmlDocument As XmlDocument

Private ValidationErrorCount As Integer

Public Sub Load()
    ValidationErrorCount = 0

    Try
        Dim XmlReader As XmlReader
        Dim XmlReaderSettings As New XmlReaderSettings()
        Dim ValidationEventHandler As New ValidationEventHandler(AddressOf XMLValidationErrorMessage)

        XmlReaderSettings.ValidationType = ValidationType.DTD
        XmlReaderSettings.DtdProcessing = DtdProcessing.Parse

        AddHandler XmlReaderSettings.ValidationEventHandler, ValidationEventHandler

        XmlReader = XmlReader.Create(FileName, XmlReaderSettings)

        XmlDocument = New XmlDocument()

        XmlDocument.Load(XmlReader)

        If 0 = ValidationErrorCount Then
            XmlDocumentWalker(XmlDocument)
        End If

    Catch Exception As Exception
        XmlDocument = Nothing
        MsgBox(Exception.Message, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Configuration file load error")
    End Try
End Sub

Private Sub XMLValidationErrorMessage(ByVal sender As Object, ByVal args As ValidationEventArgs)
    If 0 = ValidationErrorCount Then
        MsgBox(ConfigurationResource, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Configuration file invalid")
    End If

    MsgBox(args.Message, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "XML format error")

    ValidationErrorCount += 1
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:25:15+00:00Added an answer on June 12, 2026 at 9:25 am

    Because this really isn’t a question – I’m tagging it as answered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a repeated question but i'm not able to get my answer.
This is not properly a question but something more like a thought I had
This not a programming question but Most of the programmers using Eclipse should have
This is not a programming question but I hope Microsoft programmer can see this
This is not a specific question but a generic question which was in my
NOTE: sorry as this is not a programming question but i am not aware
This is not really a programming question but please bear with me as I
I thought I would post this here not so much as a question but
This is not a question about jQuery, but about how jQuery implements such a
I really hope this is not a question posed by millions of newbies, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.