Help with a simple class

Bonekrusher

Active member
Joined
Jul 4, 2007
Messages
38
Programming Experience
1-3
Hi,

I am trying to create a simple class that will read and return information from an XML file.

I am having trouble with the function. It doesnt return a value.

VB.NET:
Imports System.Xml
Imports System.Xml.XPath
Public Class BulletinXML

    Public xpath As String
    Public Function readBulletin() As String
        Dim xpathDoc As XPathDocument
        Dim xmlNav As XPathNavigator
        Dim xmlNI As XPathNodeIterator

        xpathDoc = New XPathDocument("C:\temp.xml")
        xmlNav = xpathDoc.CreateNavigator()
        xmlNI = xmlNav.Select(xpath)
        While (xmlNI.MoveNext())
            'MsgBox(xmlNI.Current.Name + " : " + xmlNI.Current.Value)
            Return (xmlNI.Current.Value)
        End While


    End Function

    
End Class

And to call the class

VB.NET:
Dim readxml As New BulletinXML
        readxml.xpath = "/ROOT/BULLETIN/@title"

        MsgBox(readxml.ToString())

I verified that the code works in a onclick event.

What am I doing wrong?

Thanks
 
You haven't called your readBulletin function that should return the string you want.
 
It's your BulletinXML class that has this method. You have an instance of this class assigned to your readxml variable, so you can use it through that.
 
You're already using the 'xpath' member of this class, why is there a problem using the 'readBulletin' member then? Also with the xml code you're using class instance members like properties and methods and seem to know how to do this very well already.
 
Back
Top