[code=vbnet]Imports System.IO
Public Class CourseDisplay
Inherits System.Windows. Forms.Form
Dim studnetcount As Integer = 0
Dim tempStr As String = ""
Dim studentID As String
Dim studentName As String
Dim program As String
Dim Students As Student() = New Student() {}
Dim StudentString As String
Private Sub Display_Load(By Val sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim document As XmlDocument = New XmlDocument
document.Load(" CP2830.xml")
Dim reader As XmlNodeReader = New XmlNodeReader(d ocument)
While reader.Read()
If reader.Name = "courseID" Then
Label1.Text = reader.ReadElem entString()
End If
If reader.Name = "courseName " Then
Label2.Text = reader.ReadElem entString()
End If
If (reader.Name = "student") Then
reader.Read()
studentID = reader.ReadElem entString()
studentName = reader.ReadElem entString()
program = reader.ReadElem entString()
studnetcount += 1
End If
End While
StudentString = (studentID + studentName + program)
ListBox1.Items. Add(StudentStri ng)
Label4.Text = studnetcount
End Sub
End Class[/code]
The problem is it read only one student but i have five student i don't where is the problem
Public Class CourseDisplay
Inherits System.Windows. Forms.Form
Dim studnetcount As Integer = 0
Dim tempStr As String = ""
Dim studentID As String
Dim studentName As String
Dim program As String
Dim Students As Student() = New Student() {}
Dim StudentString As String
Private Sub Display_Load(By Val sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim document As XmlDocument = New XmlDocument
document.Load(" CP2830.xml")
Dim reader As XmlNodeReader = New XmlNodeReader(d ocument)
While reader.Read()
If reader.Name = "courseID" Then
Label1.Text = reader.ReadElem entString()
End If
If reader.Name = "courseName " Then
Label2.Text = reader.ReadElem entString()
End If
If (reader.Name = "student") Then
reader.Read()
studentID = reader.ReadElem entString()
studentName = reader.ReadElem entString()
program = reader.ReadElem entString()
studnetcount += 1
End If
End While
StudentString = (studentID + studentName + program)
ListBox1.Items. Add(StudentStri ng)
Label4.Text = studnetcount
End Sub
End Class[/code]
The problem is it read only one student but i have five student i don't where is the problem
Comment