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.
And to call the class
I verified that the code works in a onclick event.
What am I doing wrong?
Thanks
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