rss feed


Active Member
Licensed User
Longtime User
In this RSS Feed I am trying to extract data in description and yweather tag. Dont know How to do it :sign0085:

please help

Conditions for Banashankari Stage 3, IN at 1:31 pm IST
Bangalore - Karnataka Weather Forecasts | Maps | News - Yahoo! Weather
<pubDate>Sat, 29 Oct 2011 1:31 pm IST</pubDate>
<yweather:condition text="Partly Cloudy" code="30" temp="26" date="Sat, 29 Oct 2011 1:31 pm IST"/>
<img src=""/><br /> <b>Current Conditions:</b><br /> Partly Cloudy, 26 C<BR /> <BR /><b>Forecast:</b><BR /> Sat - Showers. High: 26 Low: 19<br /> Sun - Scattered Thunderstorms. High: 26 Low: 19<br /> <br /> <a href="*">Full Forecast at Yahoo! Weather</a><BR/><BR/> (provided by <a href="" >The Weather Channel</a>)<br/>
<yweather:forecast day="Sat" date="29 Oct 2011" low="19" high="26" text="Showers" code="11"/>
<yweather:forecast day="Sun" date="30 Oct 2011" low="19" high="26" text="Scattered Thunderstorms" code="38"/>
<guid isPermaLink="false">INXX0012_2011_10_30_7_00_IST</guid>


Well-Known Member
Licensed User
Longtime User
Try with SaxParser

Hello mkvidyashankar,

THEORETICALLY, something like this should work (have not tested it).
However, the SaxParser might have problems with the "<yweather:" tag, in which
event you would need to parse the feed manually using String functions
and download the feed using GetString():

Dim feed as String
feed = Response.GetString("UTF8")
in Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)

Sub Process_Globals
   Dim Parser As SaxParser
   Dim HttpClient1 As HttpClient
   Dim wm as String
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    End If
    Request.InitializeGet("http://..................") 'your feed URL here
    If HttpClient1.Execute(Request, 1) = False Then Return
End Sub

Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
   Dim Result As InputStream
   Result = Response.GetInputStream
   Parser.Parse(Result, "Parser")
End Sub

Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
   If Parser.Parents.IndexOf("item") > -1 Then
      If Name = "yweather" Then                [COLOR="Red"]'error likely here[/COLOR]
          wm = wm & Text.ToString & CRLF
      Else If Name = "description" Then
          wm = wm & Text.ToString
      End if
   End If
End Sub
Upvote 0


B4X founder
Staff member
Licensed User
Longtime User
In what way isn't it working? I tried it and it fetches the description node correctly.
The condition node should be extracted from the attributes:
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
   If name = "condition" Then
      For i = 0 To Attributes.Size - 1
         Log("name=" & Attributes.GetName(i))
         Log("value=" & Attributes.GetValue(i))
   End If
End Sub
Upvote 0