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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:29:05+00:00 2026-05-11T23:29:05+00:00

I have the following XML: <XMLDictionary> <a>b</a> <c>d</c> <e>f</e> </XMLDictionary> I’m trying to get

  • 0

I have the following XML:

<XMLDictionary>
  <a>b</a>
  <c>d</c>
  <e>f</e>
</XMLDictionary>

I’m trying to get the mappings a: b, c: d, e: f, and I can’t quite find how to do it simply.

My current code looks like this:

    Do While reader.Read()
        If reader.NodeType = Xml.XmlNodeType.Element Then
            Me.Add(reader.Name, reader.ReadElementString)
        End If
    Loop

The problem is that I don’t know how to read the contents of the element without calling ReadElementString, and ReadElementString advances the “pointer” to the next node (so reader.Name already has the next value). When in the loop I call Read() again, i’m skipping nodes.
I’ve tried several variations on this theme, and none works perfectly, which indicates that i’m missing something important here.

Any pointers?

Thanks

  • 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-11T23:29:06+00:00Added an answer on May 11, 2026 at 11:29 pm

    I don’t know if I would use the XmlReader for what you are doing, probably just an XmlDocument, but if you want the reader, probably something like this might work:

    Dim lastNode As String = string.Empty
    Do While reader.Read()
         If reader.NodeType = Xml.XmlNodeType.Element Then
            lastNode = reader.Name
         Else If reader.NodeType = Xml.XmlNodeType.Text AND NOT string.IsNullOrEmpty(lastNode) THEN
             Me.Add(lastNode,reader.Value)
             lastNode = string.Empty    
         End If
    Loop
    

    Forgive me for any syntax errors; it’s been a while since of written in VB.net. This is a basic state machine that first detects if an Element is found and then starts looking for a text value.

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

Sidebar

Related Questions

Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I hope you can help... Let's assume I have following XML: <data> <token> <sessionId>12345</sessionId>
I have following xml which same child element (Filed) and I want to get
I have the following XML retreived from webservices.How do i get the value of
I have the following XML code. <firstname> <default length=6>Örwin</default> <short>Örwin</short> <shorter>Örwin</shorter> <shortest>�.</shortest> </firstname> Why
I have the following xml that stores table definations. How can I loop through
I have following xml structure: //this is the root <factory ver=123 id=1> //can be
I have following xml file: <ab> <![CDATA[ <table> <tbody> <tr> <th>abcdef</th> </tr> <tr> <p>
I have following xml as a response to a service not i want to
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567

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.