I want to create a program which reads xml file and puts obtained values into DataGridView. This XML file is a table dump from MySQL database. In this table I have a 'set' column where I can choose some options. Here's an example with no selected options
<size></size>
and with selected option
<size>SMALL,MEDIUM,LARGE,XLARGE</size>
Here is my code which I use to read xml file:
Dim ofile As New OpenFileDialog
If ofile.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim reader As XmlTextReader = New XmlTextReader(ofile.FileName)
Using reader
Dim toadd As String = Nothing
Dim str() As String
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element
If reader.Name.ToLower.Contains("oldIndex") Then
Exit Select
End If
Case XmlNodeType.Text
If Not reader.Value = vbNullString Or Not reader.Value = vbNullChar Then
toadd = toadd & reader.Value & vbTab
Else
toadd = toadd & "no data" & vbTab
End If
Case XmlNodeType.EndElement
If reader.Name.Contains("RECORD") Then
If toadd IsNot Nothing Then
str = toadd.Split(vbTab)
ShopTable.Rows.Add(str)
toadd = Nothing
End If
End If
End Select
Loop
End Using
End If
When there are some data between size tags, there is no problem with reading, but if there are no data, then it reads nothing and I don't receive 'no data' as a result. How do I fix this? Thanks in advance for help. Kind Regards.