471,321 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

DOM Questions

I have a class that holds my XML data.

Public Class Settings

Private Shared xmlDoc As XmlDocument

Public Shared Property Products() As XmlDocument
If xmlDoc Is Nothing Then
Dim xmlFile As String = xmlLocation()
Dim xmlDoc As XmlDocument

xmlDoc = New XmlDocument
End If

Return xmlDoc
End Get
Set(ByVal Value As XmlDocument)
xmlDoc = Value 'no real need to validate
End Set
End Property
End Class

I am trying to load this into a combobox. Here is my code (the commented out
is what I did before..)

Private Sub Zadig_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim xDoc = Settings.Products
Dim xNodeList As XmlNodeList
Dim xNode As XmlNode

xNodeList = xDoc.SelectNodes("/products/product/id")

For Each xNode In xNodeList


'While xmlTr.Read
' If xmlTr.Name = "id" AndAlso xmlTr.NodeType =
XmlNodeType.Element Then
' cmbProducts.Items.Add(xmlTr.ReadString)
' End If
'End While

'xmlDoc = New XmlDocument

End Sub

I am getting this error
An unhandled exception of type 'System.NullReferenceException' occurred in

Additional information: Object variable or With block variable not set.

The line in question is
xNodeList = xDoc.SelectNodes("/products/product/id")

Here is my XML file

<?xml version="1.0" encoding="utf-8" ?>

<!-- Repeat the structure below for each product. -->
<id>CP-90, T-32</id>
<address>Street Address</address>

<!-- Next product here-->

Any ideas?
Jul 21 '05 #1
0 831

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by softwareengineer2006 | last post: by
reply views Thread by connectrajesh | last post: by
8 posts views Thread by Krypto | last post: by
reply views Thread by ramu | last post: by
1 post views Thread by ramu | last post: by
reply views Thread by ramu | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.