Web Service To Parse RSS Feed For Data

On Thursday I developed a web service to get the New York Lotto numbers. My web service is getting the numbers from a RSS feed because it is easier to parse XML than it is to find data in HTML source code.

I reused the code from my Stickam ASPX page which uses the HttpWebRequest class of the System.Net namespace to make a request to a web server and get the response. I had the same problem with extra characters appearing at the end of the XML making it invalid so I fixed the StreamReader problem. Instead of reading a fixed number of bytes I read an entire line:


Dim Reader As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.UTF8)
Dim Writer As StringWriter = New StringWriter

Dim strLine As String
Do While Reader.Peek() >= 0
  strLine = Reader.ReadLine()
  Writer.WriteLine(strLine)
Loop

This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit exceeded. Please complete the captcha once again.