S
Shapper
Hello,
I am reading the <item> nodes from a XML file and add them to a dataset.
When I display my dataset in a datagrid I always see the same record.
It's like the For loop is not moving from one item to the next one.
This is my code:
' Load RSS File
Dim news As New XmlDocument()
news.Load("http://www.domain.com/_rss/news.rss")
' Create Dataset
Dim dsNews As DataSet = New DataSet()
dsNews.Tables.Add
dsNews.Tables(0).Columns.Add("title", GetType(String))
dsNews.Tables(0).Columns.Add("description", GetType(String))
' Read Item Nodes
Dim items As XmlNodeList =
news.SelectNodes("/rss[@version='2.0']/channel/item")
For Each item As XmlNode In items
Dim row As DataRow = dsNews.Tables(0).NewRow()
row.Item("title") =
CType(news.SelectSingleNode("/rss[@version='2.0']/channel/item/title").InnerText,
String)
row.Item("description") =
CType(news.SelectSingleNode("/rss[@version='2.0']/channel/item/description").InnerText,
String)
dsNews.Tables(0).Rows.Add(row)
Next
Can someone tell me what is wrong?
Thank You,
Miguel
I am reading the <item> nodes from a XML file and add them to a dataset.
When I display my dataset in a datagrid I always see the same record.
It's like the For loop is not moving from one item to the next one.
This is my code:
' Load RSS File
Dim news As New XmlDocument()
news.Load("http://www.domain.com/_rss/news.rss")
' Create Dataset
Dim dsNews As DataSet = New DataSet()
dsNews.Tables.Add
dsNews.Tables(0).Columns.Add("title", GetType(String))
dsNews.Tables(0).Columns.Add("description", GetType(String))
' Read Item Nodes
Dim items As XmlNodeList =
news.SelectNodes("/rss[@version='2.0']/channel/item")
For Each item As XmlNode In items
Dim row As DataRow = dsNews.Tables(0).NewRow()
row.Item("title") =
CType(news.SelectSingleNode("/rss[@version='2.0']/channel/item/title").InnerText,
String)
row.Item("description") =
CType(news.SelectSingleNode("/rss[@version='2.0']/channel/item/description").InnerText,
String)
dsNews.Tables(0).Rows.Add(row)
Next
Can someone tell me what is wrong?
Thank You,
Miguel