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

  • Home
  • SEARCH
  • 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 756067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:12:10+00:00 2026-05-14T15:12:10+00:00

I’m having a problem with looping through an XML file and storing the value

  • 0

I’m having a problem with looping through an XML file and storing the value in a singleton

My XML looks like this

<values>
    <value></value>
    <value>$1</value>           
    <value>$5,000</value>       
    <value>$10,000</value>      
    <value>$15,000</value>      
    <value>$25,000</value>      
    <value>$50,000</value>      
    <value>$75,000</value>      
    <value>$100,000</value>     
    <value>$250,000</value>     
    <value>$500,000</value>     
    <value>$750,000</value>     
    <value>$1,000,000</value>   
    <value>$1,250,000</value>   
    <value>$1,500,000</value>   
    <value>$1,750,000</value>   
    <value>$2,000,000</value>   
    <value>$2,500,000</value>   
    <value>$3,000,000</value>   
    <value>$4,000,000</value>   
    <value>$5,000,000</value>   
    <value>$7,500,000</value>   
    <value>$10,000,000</value>  
    <value>$15,000,000</value>  
    <value>$25,000,000</value>  
    <value>$50,000,000</value>  
    <value>$100,000,000</value> 
    <value>$100,000,000+</value>
</values>

And my function looks like this

Public Class LoadValues
    Private Shared SearchValuesInstance As List(Of SearchValues) = Nothing

    Public Shared ReadOnly Property LoadSearchValues As List(Of SearchValues)
        Get
            Dim sv As New List(Of SearchValues)

            If SearchValuesInstance Is Nothing Then
                Dim objDoc As XmlDocument = New XmlDataDocument
                Dim objRdr As XmlTextReader = New XmlTextReader(HttpContext.Current.Server.MapPath("~/App_Data/Search-Values.xml"))
                objRdr.Read()
                objDoc.Load(objRdr)

                Dim root As XmlElement = objDoc.DocumentElement
                Dim itemNodes As XmlNodeList = root.SelectNodes("/values")

                For Each n As XmlNode In itemNodes
                    sv.Add(New SearchValues(n("@value").InnerText, n("@value").InnerText))
                Next
                SearchValuesInstance = sv

            Else : sv = SearchValuesInstance
            End If

            Return sv
        End Get
    End Property

End Class

My problem is that I’m getting an object not set to an instance of an object on the sv.Add(New SearchValues(n("@value").InnerText, n("@value").InnerText)) line.

  • 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-14T15:12:10+00:00Added an answer on May 14, 2026 at 3:12 pm

    Ok, I seem to have found my answer. Hopefully this will help the next person with the same problem.

    Public Class LoadValues
        Private Shared SearchValuesInstance As List(Of SearchValues) = Nothing
    
        Public Shared ReadOnly Property LoadSearchValues As List(Of SearchValues)
            Get
                Dim sv As New List(Of SearchValues)
    
                If SearchValuesInstance Is Nothing Then
    
                    Dim objDoc As XmlDocument = New XmlDataDocument
                    objDoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/Search-Values.xml"))
    
                    Dim root As XmlNode = objDoc.DocumentElement
                    Dim nodelist As XmlNodeList = root.SelectNodes("/values/value")
    
                    Dim value As Double
    
                    For Each n As XmlNode In nodelist
                        value = If(BizHelper.ConvertToDouble(n.InnerText) Is Nothing, 0, BizHelper.ConvertToDouble(n.InnerText))
                        sv.Add(New SearchValues(n.InnerText, value))
                    Next
    
                    SearchValuesInstance = sv
    
                Else : sv = SearchValuesInstance
                End If
    
                Return sv
            End Get
        End Property
    
        Public Shared Sub DisposeSearchValues()
            SearchValuesInstance = Nothing
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could try something like this maybe? private void AddAutoIncrementColumn()… May 14, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer Instead of using Run Script (F5), use Run Statement (Ctrl+Enter).… May 14, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer Try the ModeChanged event. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.modechanged.aspx update.. Try this DropDownList ddl… May 14, 2026 at 9:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.