|
-
Dec 5th, 2009, 02:04 PM
#1
Thread Starter
Junior Member
Last edited by DumbAndDumber; Dec 5th, 2009 at 03:19 PM.
Reason: Removed a confusing line of code unneeded
-
Dec 5th, 2009, 03:08 PM
#2
Re: ListView/XML Problem
vb Code:
Dim rdrXML As New Xml.XmlTextReader("WebSites.xml")
rdrXML.MoveToContent()
Dim ElementName As String = ""
Dim objListViewItem As ListViewItem = Nothing
Do While rdrXML.Read
If rdrXML.NodeType = 1 Then
ElementName = rdrXML.Name
ElseIf rdrXML.NodeType = 3 Then
If ElementName = "Name" Then
objListViewItem = New ListViewItem(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
ListView1.Items.Add(objListViewItem)
End If
Loop
rdrXML.Close()
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 5th, 2009, 03:16 PM
#3
Thread Starter
Junior Member
Re: ListView/XML Problem
Thanks, .paul. for your post, however, I get the following exception (translated):
Code:
System.ArgumentException was unhandled
Unable to add ASP.NET on more than one place. Remove the item from the current location or copy it.
ParamName="item"
Source="System.Windows.Forms"
Form1.vb:line 21
P.S.: ASP.NET is a node in the XML file (to prevent confusion).
Last edited by DumbAndDumber; Dec 5th, 2009 at 03:19 PM.
 If my post helped you out, please rate me!
 Thread resolved? Mark it as Resolved!
-
Dec 5th, 2009, 04:25 PM
#4
Re: ListView/XML Problem
try this:
vb Code:
Dim doc As New Xml.XmlDocument
doc.Load("WebSites.xml")
For Each node As Xml.XmlNode In doc.SelectNodes("WebSites/WebSite")
Dim objListViewItem As New ListViewItem(node.SelectSingleNode("Name").InnerText)
objListViewItem.SubItems.Add(node.SelectSingleNode("URL").InnerText)
objListViewItem.SubItems.Add(node.SelectSingleNode("Info").InnerText)
ListView1.Items.Add(objListViewItem)
Next
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 5th, 2009, 04:27 PM
#5
Thread Starter
Junior Member
Re: ListView/XML Problem
Thanks a lot! Very short, simple piece of code but it works very well! Thanks once again
 If my post helped you out, please rate me!
 Thread resolved? Mark it as Resolved!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|