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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:02:25+00:00 2026-05-28T02:02:25+00:00

Hey all i have an XML file that i am trying to loop though.

  • 0

Hey all i have an XML file that i am trying to loop though. My current code does this just fine BUT it only does it for the first 2 nodes. It repeats nodes over and over again.

My XML structor is like this:

 <?xml version="1.0" encoding="Windows-1252"?>
 <stn1110>
    <jobid>-87</jobid>
    <sn_siab>677 6086tyhg67y</sn_siab>
    <jobid>-35667</jobid>
    <sn_siab>677 63436hyh</sn_siab>
    <jobid>-357689</jobid>
    <sn_siab>677 87888888</sn_siab>
    <jobid>-50000</jobid>
    <sn_siab>677 gdfr4365454</sn_siab>
    <jobid>-366877</jobid>
    <sn_siab>677 nfrrt444445</sn_siab>
 </stn1110>

And my currrent VB.net code is this:

    Dim file As String = "C:\bin\Debug\stn1110.xml"

    Dim m_xmld As XmlDocument
    Dim m_nodelist As XmlNodeList
    Dim m_node As XmlNode

    m_xmld = New XmlDocument()
    m_xmld.Load(file)
    MessageBox.Show(m_xmld.OuterXml)
    m_nodelist = m_xmld.SelectNodes("/stn1110")

    For Each m_node In m_nodelist
        Dim firstNameValue = m_node.ChildNodes.Item(0).InnerText
        Dim lastNameValue = m_node.ChildNodes.Item(1).InnerText

        Debug.Print(firstNameValue)
        Debug.Print(lastNameValue)
    Next

How can i loop through the whole thing while still gathing only the 2 childnodes every loop?

Thanks,

David

  • 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-28T02:02:26+00:00Added an answer on May 28, 2026 at 2:02 am

    Your m_nodelist contains only one entry, because there is only one stn1110 node.

    What you probably want is to output its 0+1-st child in the first loop iteration, its 2+3-rd child in the second iteration, etc. Thus, you could do something like this:

    Dim m_node = m_xmld.SelectSingleNode("/stn1110")
    
    For i = 0 To m_node.ChildNodes.Count - 1 Step 2
        Dim firstNameValue = m_node.ChildNodes.Item(i).InnerText
        Dim lastNameValue = m_node.ChildNodes.Item(i+1).InnerText
    
        Debug.Print(firstNameValue)
        Debug.Print(lastNameValue)
    Next i
    

    (Hooray, finally some use case for the Step keyword!)

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

Sidebar

Related Questions

Hey all, basically i have an empty AS3 fla file with just the following
Hey all, i have been trying for a few minutes on this problem and
Hey all, this is the code i have to check for a day thats
Hey all i am new to XML parsing on VB.net. This is the code
hey guys, we have a loop that: 1.Loops over several thousand xml files. Altogether
Hey all i have code to write to an xml doc from asp string
Hey All! I am trying to use wonderxml (http://code.google.com/p/wonderxml/) to convert my xml into
Hey all i have a mind bug with this wile loop , i am
Hey all, i have a problem with trying to get 2 forms to close
Hey all. Here is the scenario. I have the below code, and I'm needing

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.