471,317 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

New to Classes

created a class to hold my XML DOM data.

visual basic
code:--------------------------------------------------------------------------------Public Class Settings

Public Shared xmlDoc As XmlDocument

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

xmlDoc = New XmlDocument
xmlDoc.Load(xmlFile)
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 get it to display the id field in a combobox I am not sure
how to do this. I tried this but I was getting some nullexception error.
visual basic
code:-------------------------------------------------------------------------------- Dim xDoc As Settings
xDoc = New Settings

Dim xNodeList As XmlNodeList
Dim xNode As XmlNode

Dim xDoc2 = xDoc.thexml


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

For Each xNode In xNodeList

cmbProducts.Items.Add(xNode.InnerText)

Next--------------------------------------------------------------------------------

here is my xml in caase it makes a difference...
Code:
<?xml version="1.0" encoding="utf-8" ?>

<products>
<!-- Repeat the structure below for each product. -->
<product>
<id>CP-90, T-32</id>
<company>Carwell</company>
<address>Street Address</address>
<city>City</city>
<state>State</state>
<zip>Zip</zip>
</product>

<!-- Next product here-->
</products>

Please help, I am at a total loss.....
Jul 21 '05 #1
0 672

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Aguilar, James | last post: by
12 posts views Thread by Langy | last post: by
4 posts views Thread by john townsley | last post: by
18 posts views Thread by Edward Diener | 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.