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 6998585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:25:48+00:00 2026-05-27T20:25:48+00:00

I am trying to parse this xml file, which has some nested nodes. I

  • 0

I am trying to parse this xml file, which has some nested nodes. I don’t know how to put the xml file content that looks neat here. if you can tell me how, that would be great too.

And this is my code. I am able to retrieve some info, but some of them is not correct (strGrant has values that is supposed to be for strSupport).
Can someone tell me what is wrong with my code. I am a newbie here. any help is appreciated!

    Dim strGrant, strSupport, strDatabank, strWeight, strNumOfGrants, strNumOfSupports, strNumOfDatabanks As String

    While XmlReader.Read()
        Console.WriteLine("{0}: {1}", XmlReader.NodeType.ToString(), XmlReader.Name)

        If XmlReader.Name.ToString() = "GrantInfo/NumberOfGrants" Then strNumOfGrants = Trim(XmlReader.ReadString())

        If XmlReader.Name.ToString() = "NumberOfGrants" Then strNumOfGrants = Trim(XmlReader.ReadString())

        If (XmlReader.Name.ToString() = "Grant/CLabelInfo") Then strGrant = XmlReader.ReadString()

        If XmlReader.Name.ToString() = "Name" Then strGrant = XmlReader.ReadString()
        '    ''End If

        If XmlReader.Name.ToString() = "CleanUpData/DatabankInfo/NumberOfDatabanks" Then strNumOfDatabanks = Trim(XmlReader.ReadString())

        If XmlReader.Name.ToString() = "NumberOfDatabanks" Then strNumOfDatabanks = Trim(XmlReader.ReadString())

        If XmlReader.Name.ToString() = "Databank/CLabelInfo" Then strDatabank = Trim(XmlReader.ReadString())

        If XmlReader.Name.ToString() = "Name" Then strDatabank = XmlReader.ReadString()

        If XmlReader.Name.ToString() = "Confidence" Then strWeight = XmlReader.ReadString()


        If XmlReader.Name.ToString() = "Name" And XmlReader.NodeType.ToString() = "EndElement" Then

            Response.Write("- Number of Grants: " & strNumOfGrants & "<br>")
            Response.Write("- Grant Numbers: " & strGrant & "<br>")         

        End If
        If XmlReader.Name.ToString() = "CleanUpData/SupportInfo/NumberOfSupports" Then strNumOfSupports = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "NumberOfSupports" Then strNumOfSupports = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "Support/CLabelInfo" Then strSupport = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "Name" Then strSupport = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "CLabelInfo" And XmlReader.NodeType.ToString() = "EndElement" Then
            Response.Write("- Number of Supports: " & strNumOfSupports & "<br>")
            Response.Write("- Support Number: " & strSupport & "<br>")

        End If
        If XmlReader.Name.ToString() = "CleanUpData/DatabankInfo/NumberOfDatabanks" Then strNumOfSupports = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "NumberOfDatabanks" Then strNumOfDatabanks = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "Databank/CLabelInfo" Then strDatabank = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "Name" Then strDatabank = Trim(XmlReader.ReadString())
        If XmlReader.Name.ToString() = "CLabelInfo" And XmlReader.NodeType.ToString() = "EndElement" Then
            Response.Write("- Number of Databanks: " & strNumOfDatabanks & "<br>")
            Response.Write("- Databank Number: " & strDatabank & "<br>")

        End If
    End While
    XmlReader.Close()

This is my result:

Number of Grants: 1
– Grant Numbers: DK30111
– Number of Supports:
– Support Number:
– Number of Databanks:
– Databank Number:
– Number of Grants: 1
– Grant Numbers: NIHExtra
– Number of Supports: 1
– Support Number:
– Number of Databanks:
– Databank Number:
– Number of Grants: 1
– Grant Numbers: RefSeq/NM_007614
– Number of Supports: 1
– Support Number:
– Number of Databanks:
– Databank Number:
– Number of Grants: 1
– Grant Numbers: RefSeq/NM_008084
– Number of Supports: 1
– Support Number:
– Number of Databanks:
– Databank Number:
– Number of Grants: 1
– Grant Numbers: [NOT FOUND]
– Number of Supports: 1
– Support Number:
– Number of Databanks:
– Databank Number:

  • 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-05-27T20:25:49+00:00Added an answer on May 27, 2026 at 8:25 pm

    This is because you are using the node Name incorrectly. The node name will only contain the current node’s name, not the name hierarchy.

    So you will need to change your name statements to reflect this. It will also be more efficient if the comparison was in a case statement. Finally, to account for fluctuations in the casing of the file, you should compare either upper or lowercase.

    Here is an example:

    Select Case XmlReader.Name.ToString().ToLower
        Case "numberofgrants" 
            strNumOfGrants = Trim(XmlReader.ReadString())
    
    End Select
    

    You should be able to convert the rest to this format.

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

Sidebar

Related Questions

I'm trying to parse an xml file that has the contents of a simple
I am beginner in PHP. I am trying to parse this xml file. <relationship>
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse a log file that looks like this: %%%% 09-May-2009 04:10:29
I'm trying to parse UTF-8 XML file and save some parts of it to
I'm trying to read in an xml file which looks like this <?xml version=1.0
I'm trying to parse an NZB file (which is XML) and sum the bytes
I have this XML file that I parse into its elements and create a
I am trying to parse this XML file for a school project: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/genre=20/xml .
I have a weird XML file that I'm trying to parse. <Data> <Row> <Field

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.