• 0

[VB.Net]Windows Mobile RSS


Question

Im working on a simple application that will grab RSS feeds from a website and display them when the program is loaded.

But i cant find any windows mobile relevent code and have no idea where to go.

My RSS has the following content that needs to be extracted. Each content is labeled at <item> and there is about 6 of them in the RSS feed.

Of course ya have all the normal RSS stuff that descripes what the RSS feed is.

	&lt;item&gt;
	  &lt;title&gt;Testing&lt;/title&gt;
	  &lt;description&gt;Description here&lt;/description&gt;
	  &lt;link&gt;http://192.168.2.1/testing.htm&lt;/link&gt;
	  &lt;guid isPermaLink="false"&gt;http://192.168.2.1/testing.htm&lt;/guid&gt;
	  &lt;pubDate&gt;Mon, 01 Jan 2000 00:00:00 GMT&lt;/pubDate&gt;
	  &lt;category&gt;6&lt;/category&gt;
	&lt;/item&gt;

How can this be done in VB.NET for Windows Mobile. As i dont really know C++

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hey,

Windows Mobile supports the .NET Compact Framework, which supports a subset of the full .NET Framework's Xml functionality.

A good place to start would be here.

As long as you get the xml, you can pass it to something like an XmlTextReader, or an XmlDocument and you should be fine. Make sure you check on that page what exactly the Compact Framework can and can't do in regards to Xml.

MSDN is your friend :)

Link to comment
Share on other sites

  • 0

Yer i did read that but i cant find any sample code for windows mobile that shows me how to grab and read XML from a web url

Link to comment
Share on other sites

  • 0

Well, the mobile code is essentially the same as the desktop code:

	Public Function GetXmlContent(ByVal uri As String) As XmlTextReader
		If (String.IsNullOrEmpty(uri)) Then
			Throw New ArgumentNullException(uri)
		End If

		Dim reader As XmlTextReader = New XmlTextReader(uri)

		Return reader
	End Function

And you should be able to call it using:

Dim reader As XmlTextReader = GetXmlContent("http://feeds.neowin.net/neowin-forum")

Then just process your xml. If you'd prefere to use something like an XmlDocument, you'd need to read the entire xml stream before you create the document:

	Public Function GetXmlContent(ByVal uri As String) As XmlDocument
		If (String.IsNullOrEmpty(uri)) Then
			Throw New ArgumentNullException(uri)
		End If

		Dim request As HttpWebRequest = WebRequest.Create(uri)
		Dim response As HttpWebResponse = request.GetResponse()

		Dim reader As StreamReader = New StreamReader(response.GetResponseStream())

		Dim document As XmlDocument = New XmlDocument()
		document.LoadXml(reader.ReadToEnd())

		reader.Close()

		Return document
	End Function

Don't forget though, an XmlDocument keeps the xml in memory, but you get the perks of being able to manipulate and search through the Xml DOM. I'd recommend using an XmlTextReader in a mobile environment for the performance benenifts, but the caveat of that is it is a forward-only stream reader.

Hope that helps getting you started, but you may want to validate some of that code, its all from the head :p

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.