System.NullReferenceException: 'Object reference not set to an instance of an object.'
If feedImage.SelectSingleNode("url") IsNot Nothing Then
Public Function FillFeedList(combo As ComboBox, category As String) 'Connect to Internal Feed Database Dim path As String = "RSSFeeds.xml" Dim feedDoc As New XmlDocument() feedDoc.Load(path) Dim selectedCategory As XmlNodeList = feedDoc.SelectNodes("category/" + category) Dim i As Integer = 0 For Each node In selectedCategory.Item(i) Dim feedLink As XmlNode = selectedCategory.Item(i).SelectSingleNode("link") If feedLink IsNot Nothing Then 'combo.Items.Add(feedLink.InnerText) combo.DataSource = (From element In feedLink Select element.Value).ToList() Else combo.Text = Nothing End If Next i += 1 Return Nothing End Function
<?xml version="1.0"?> <category> <earthquake> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </earthquake> <volcano> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </volcano> <hurricane> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </hurricane> <tsunami> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </tsunami> <space> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </space> <disease> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </disease> <custom> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </custom> </category>
<category> <earthquake> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </earthquake> <volcano> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </volcano> <hurricane> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </hurricane> <tsunami> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </tsunami> <space> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </space> <disease> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </disease> <custom> <link>https://www.volcanodiscovery.com/volcanonews.rss</link> </custom></category>
Public Function GetFeeds(ByVal FeedsDoc As XDocument, ByVal category As String) As String() If (FeedsDoc Is Nothing) Then Throw New ArgumentNullException(NameOf(FeedsDoc)) End If Dim node As XmlElement = CType(FeedsDoc.Elements("/category/" + category + "/link"), XmlElement) If (node IsNot Nothing) Then Return node.InnerText.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) Else Return New String() {} End If End Function