Hello other friendly developers!
I've got a little frustrating problem, because I can't find the problem in my code:
1: I've got a form containing one control (ListView1, a ListView control)
2: I've got this XML File (WebSites.xml)
3: I've got this VisualBasic.NET2 code:Code:<?xml version="1.0" encoding="utf-8"?> <WebSites> <WebSite> <Name>ASP.NET</Name> <URL>http://www.asp.net</URL> <Info>Hierzo Info</Info> </WebSite> <WebSite> <Name>Windows Forms</Name> <URL>http://www.windowsforms.net</URL> <Info>All about Windows Forms</Info> </WebSite> <WebSite> <Name>GotDotNet</Name> <URL>http://www.gotdotnet.com</URL> <Info>GotDotNet Programme</Info> </WebSite> </WebSites>
However, I get this strange result. I want all the properties in one row (For each website a row containing Name, URL and Info).Code:Dim rdrXML As New Xml.XmlTextReader("WebSites.xml") rdrXML.MoveToContent() Dim ElementName As String = "" Dim objListViewItem As ListViewItem = Nothing Do While rdrXML.Read objListViewItem = New ListViewItem ListView1.Items.Add(objListViewItem) If rdrXML.NodeType = 1 Then ElementName = rdrXML.Name ElseIf rdrXML.NodeType = 3 Then If ElementName = "Name" Then objListViewItem.Text = rdrXML.Value End If If ElementName = "URL" Then objListViewItem.SubItems.Add(rdrXML.Value.ToString) End If If ElementName = "Info" Then objListViewItem.SubItems.Add(rdrXML.Value.ToString) End If End If Loop rdrXML.Close()
Can anyone help me? This really makes my head feel like exploding!![]()




Reply With Quote
