0
我在通過一個XML文件循環,並在單VB.NET通過XML循環存儲在單
我的XML看起來像這樣
<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>
存儲值存在問題而我的功能看起來像這樣
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
我的問題是,我在sv.Add(New SearchValues(n("@value").InnerText, n("@value").InnerText))
線得到一個object not set to an instance of an object
。