0

I am creating a custom (private, non-commercial) utility to parse RSS feeds. Since it's been a few years since I've had a need to do this, I referred to an example at CodeDisplay.com

I'm providing the code in VB.NET, however - I'm sure C# programmers can recognize the concepts also.

In short, the code in question is as follows. My first iteration used a Reuters feed.

Dim MyRssRequest As WebRequest = WebRequest.Create("http://feeds.reuters.com/reuters/topNews")
Dim MyRssResponse As WebResponse = MyRssRequest.GetResponse()

Dim MyRssStream As Stream = MyRssResponse.GetResponseStream()

Dim MyRssDocument As XmlDocument = New XmlDocument()
MyRssDocument.Load(MyRssStream)

Dim MyRssList As XmlNodeList = MyRssDocument.SelectNodes("rss/channel/item")

Dim sTitle As String = ""
Dim sLink As String = ""
Dim sDescription As String = ""

'Iterate/Loop through RSS Feed items
For i As Integer = 0 To MyRssList.Count - 1
...

This code works as desired. However - if I change the respective lines to the following (to another news source):

Dim MyRssRequest As WebRequest = WebRequest.Create("http://api.breakingnews.com/api/v1/item/?format=rss")

...and...

Dim MyRssList As XmlNodeList = MyRssDocument.SelectNodes("feed/entry")

...this code can not seem to find any "entry" items. I'm using the tools at http://xmlgrid.net/ to sanity check my understanding of the hierarchy. This tool seems to report that both XML structures are well formed.

I am curious if the .NET XML (System.xml) is sensitive on "End of Line" characters, but I find this doubtful.

I feel this is something simple that I am overlooking.

UPDATE:

I am able to step through the items by using

 Dim MyRssList As XmlNodeList = MyRssDocument.ChildNodes(1).ChildNodes

I must be missing something on my understanding of this document's XPath. I would like to be able to use the .SelectNodes method (function) using the XPath.

sonnik
  • 101
  • 1
  • XML does not have "lines". End of Line characters are whitespace and are mostly ignored. – John Saunders Jan 05 '15 at 18:27
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jan 05 '15 at 18:28
  • You are missing the XML namespace in the document from breakingnews.com. The duplicate question tells you how to deal with that. – Tomalak Jan 05 '15 at 20:59
  • @Tomalak Thank you - the referenced answer was what I needed. – sonnik Jan 05 '15 at 22:07

0 Answers0