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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:13:08+00:00 2026-05-20T00:13:08+00:00

I am trying to parse this XML file with this type of layout: <POX>

  • 0

I am trying to parse this XML file with this type of layout:

<POX>
  <LIST>
    <COMPANY>
      <A_COMPANY>The company here</A_COMPANY>
      <A_ID>786</A_ID>
      <A_BASE>USD</A_BASE>
      <A_YES>Yes</A_YES>
      <A_NO>No</A_NO>
      <A_CATEGORY_D>1210043021</A_CATEGORY_D>
      <A_PRECISION>2</A_PRECISION>
      <LIST_BREAK>
        <G_BREAK>
          <CURRENCY>2</CURRENCY>
          <SORT_COLUMN>100</SORT_COLUMN>
           etc....
        </G_BREAK>
        <G_BREAK>
          <CURRENCY>25</CURRENCY>
          <SORT_COLUMN>130</SORT_COLUMN>
           etc....
        </G_BREAK>
        <G_BREAK>
          <CURRENCY>77</CURRENCY>
          <SORT_COLUMN>1350</SORT_COLUMN>
           etc....
        </G_BREAK>
      </LIST_BREAK>
  ETC........

And i cant seem to get this code working for it:

    Dim m_xmlr As XmlTextReader
    m_xmlr = New XmlTextReader("c:\temp\46659024.xml")
    m_xmlr.WhitespaceHandling = WhitespaceHandling.None
    m_xmlr.Read()
    m_xmlr.Read()

    While Not m_xmlr.EOF
        m_xmlr.Read()

        If Not m_xmlr.IsStartElement() Then
            Exit While
        End If

        Dim strTest1 = m_xmlr.GetAttribute("/POX/LIST/COMPANY/LIST_BREAK/G_BREAK")

        m_xmlr.Read()

        Dim strTest2 = m_xmlr.ReadElementString("CURRENCY")
        Dim strTest3 = m_xmlr.ReadElementString("SORT_COLUMN")

        Console.WriteLine("test1: " & strTest1 _
          & " test2: " & strTest2 & " test3: " _
          & strTest3)
        Console.Write(vbCrLf)
        Console.Read()
    End While

I get an error on

 Dim **strTest2 = m_xmlr.ReadElementString("CURRENCY")**

Saying:

 Element 'CURRENCY' was not found. Line 4, position 4.

Also, strTest1 returns as nothing

What could i be doing incorrectly?

Thanks!

update
This is working but it doesn’t seem to get all the items..

    m_xmld = New XmlDocument()
    m_xmld.Load("c:\temp\o1293688.xml")
    m_nodelist = m_xmld.SelectNodes("/POXPOVPS/LIST_G_COMPANY/G_COMPANY/LIST_G_VENDORS_BREAK/G_VENDORS_BREAK")

    Dim ListItem1 As ListViewItem

    'Loop through the nodes
    For Each m_node In m_nodelist
        vendorName(x) = m_node.ChildNodes.Item(3).InnerText 'Name of Vendor
        ListItem1 = ListView1.Items.Add(vendorName(x), 1)
        x = x + 1
    Next

    x = 0

    m_nodelist = m_xmld.SelectNodes("/POXPOVPS/LIST_G_COMPANY/G_COMPANY/LIST_G_VENDORS_BREAK/G_VENDORS_BREAK/LIST_G_SITE_1/G_SITE_1")

    For Each m_node In m_nodelist
        vendorAddress(x) = m_node.ChildNodes.Item(0).InnerText 'Address of Vendor
        vendorTotal(x) = m_node.ChildNodes.Item(5).InnerText 'Total for vendor
        ListView1.Items(0).SubItems.Add(vendorAddress(x))
        ListView1.Items(0).SubItems.Add(vendorTotal(x))
        x = x + 1
    Next

The vendorName gets a total of x = 1435
The vendorAddress and vendorTotal gets a total of x = 1481….. Thats not going to be good when putting the values all together….

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-20T00:13:09+00:00Added an answer on May 20, 2026 at 12:13 am

    You can use this for starters..

        ' Load XML from somewhere...
        Dim xml As XElement = XElement.Parse(GetXML())
    
        ' Traverse.
        For Each company In xml.Element("LIST").Elements("COMPANY")
    
            Console.WriteLine(String.Format("Company: {0}", company.Element("A_COMPANY").Value))
            For Each gBreak In company.Element("LIST_BREAK").Elements("G_BREAK")
    
                Console.WriteLine(String.Format("Currency: {0}", gBreak.Element("CURRENCY").Value))
                Console.WriteLine(String.Format("Sort Column: {0}", gBreak.Element("SORT_COLUMN").Value))
            Next
    
        Next
    

    ‘ The GetXML() function just returns a string, it can come from a file, db, XML literal etc.

    Code was tested and yielded the following…

    Company: The company here
    Currency: 2
    Sort Column: 100
    Currency: 25
    Sort Column: 130
    Currency: 77
    Sort Column: 1350

    Private Function GetXML() As String
        Return <POX>
                   <LIST>
                       <COMPANY>
                           <A_COMPANY>The company here</A_COMPANY>
                           <A_ID>786</A_ID>
                           <A_BASE>USD</A_BASE>
                           <A_YES>Yes</A_YES>
                           <A_NO>No</A_NO>
                           <A_CATEGORY_D>1210043021</A_CATEGORY_D>
                           <A_PRECISION>2</A_PRECISION>
                           <LIST_BREAK>
                               <G_BREAK>
                                   <CURRENCY>2</CURRENCY>
                                   <SORT_COLUMN>100</SORT_COLUMN>
    
                               </G_BREAK>
                               <G_BREAK>
                                   <CURRENCY>25</CURRENCY>
                                   <SORT_COLUMN>130</SORT_COLUMN>
    
                               </G_BREAK>
                               <G_BREAK>
                                   <CURRENCY>77</CURRENCY>
                                   <SORT_COLUMN>1350</SORT_COLUMN>
                               </G_BREAK>
                           </LIST_BREAK>
                       </COMPANY>
                   </LIST>
               </POX>.ToString()
    End Function
    
    • 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 this feed: http://musicbrainz.org/ws/1/artist/c0b2500e-0cef-4130-869d-732b23ed9df5?type=xml&inc=url-rels I want to grab the URLs inside
I'm getting this error (see title) while trying to parse an XML file in
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'm trying to parse this xml file but i can't find a way to
I'm trying to parse a XML file using TBXML . However, this parser has
I am trying to parse an xml file using XmlReader but although I am
I'm trying to parse an xml file from a website. Let's say the website
While trying to parse an xml file into table format, jQuery keeps closing my
Hey guys. I'm trying to parse xml file in order to extract some data
Here is part of the xml I am trying to parse: <?xml version=1.0 encoding=UTF-8?>

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.