Android Question RSS reading?

ilan

Expert
Licensed User
Longtime User
hi,

i am trying to download the RSS from this link: rss

this is what i get:
<rss version="2.0"><channel><title>&#1488;&#1494;&#1492;&#1512;&#1493;&#1514; &#1493;&#1492;&#1514;&#1512;&#1488;&#1493;&#1514; &#1502;&#1493;&#1511;&#1491;&#1502;&#1493;&#1514;</title><link>https://www.ims.gov.il/he/IMSWarnings</link><description>description</description><language>he</language><lastBuildDate>Tue, 02 Nov 2021 23:25:00 GMT</lastBuildDate><ttl>15</ttl><item><guid isPermaLink="false">Tue, 02 Nov 2021 19:34:00 GMT</guid><title>&#1497;&#1501; &#1490;&#1489;&#1493;&#1492; &#1493;&#1502;&#1505;&#1493;&#1499;&#1503; &#1500;&#1512;&#1495;&#1510;&#1492; &#1506;&#1493;&#1491;&#1499;&#1503; &#1489;-02/11 21:34</title><link>https://www.ims.gov.il/he/IMSWarnings</link><description>&lt;p style='padding-bottom:30px;'&gt; &#1506;&#1491;&#1499;&#1493;&#1503;: &#1488;&#1494;&#1492;&#1512;&#1492; &#1495;&#1502;&#1493;&#1512;&#1492; &#1506;&#1500; &#1497;&#1501; &#1490;&#1489;&#1493;&#1492; &#1493;&#1502;&#1505;&#1493;&#1499;&#1503; &#1500;&#1512;&#1495;&#1510;&#1492; &#1489;&#1497;&#1501; &#1492;&#1514;&#1497;&#1499;&#1493;&#1503; &#1502;-02/11 &#1489;-22 &#1506;&#1491; 03/11 &#1489;-10. &#1502;&#1510;&#1489; &#1492;&#1497;&#1501; &#1490;&#1500;&#1497; &#1506;&#1491; &#1490;&#1489;&#1492; &#1490;&#1500;&#1497;&#1501;. &#1490;&#1493;&#1489;&#1492; &#1492;&#1490;&#1500; &#1492;&#1505;&#1497;&#1490;&#1504;&#1497;&#1508;&#1497;&#1511;&#1504;&#1496;&#1497; &#1497;&#1504;&#1493;&#1506; &#1502;- 120 &#1506;&#1491; 180 &#1505;"&#1502;, &#1500;&#1488; &#1510;&#1508;&#1493;&#1497; &#1513;&#1497;&#1504;&#1493;&#1497; &#1502;&#1513;&#1502;&#1506;&#1493;&#1514;&#1497;. &lt;/p&gt;</description><pubDate>Tue, 02 Nov 2021 19:34:00 GMT</pubDate></item></channel></rss>

the problem is i get this because of the Hebrew letters.
how can i convert it back to hebrew?

i am using xml2map to convert the string to a map but the problem is that it is not readable.

this is the relevant code:

B4X:
Dim haifaUrl As String = "https://ims.gov.il/sites/default/files/ims_data/rss/alert/rssAlert_general_country_he.xml"
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(haifaUrl)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString2("ASCII"))       
    End If
    j.Release

i tried UTF8 and ASCII but i get the same.
i also tried to decode it as a Base64 string but no luck, any help would be very appreciated. :)

thanx.
 
Solution
test: xml2jon and xmlbuilder
B4X:
Public Sub TestAPIGetRSS

'    Dim BaseURL As String = "https://ims.gov.il/sites/default/files/ims_data/rss/alert/rssAlert_general_country_he.xml"
    Dim BaseURL As String = "http://www.ynet.co.il/Integration/StoryRss2.xml"
       
    Wait For (APIGetRSS(BaseURL)) Complete (Result As String)
    If Result.Length = 0 Then Return
   
    Dim xml As Xml2Map
    xml.Initialize
    Dim ParsedData As Map = xml.Parse(Result)
    TextArea1.Text = ParsedData.As(JSON).ToString
   
End Sub


Public Sub APIGetRSS(URL As String) As ResumableSub
    Dim ResultURL As String
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.Download(URL)
        Wait For (j) JobDone(j As HttpJob)
        If...

DonManfred

Expert
Licensed User
Longtime User
i also tried to decode it as a Base64 string
There is no base64 in the scnippet you posted.
The problem is that there are severyl html entities in th e result. Open the rss in a webbrowser and it will work i guess.

What about using it in another language. Like english?

B4X:
https://ims.gov.il/sites/default/files/ims_data/rss/alert/rssAlert_general_country_en.xml

Edit: You maybe can use jsoup (there is a library) to get the plain-text (html entities are converted).
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
The problem is that there are severyl html entities in th e result. Open the rss in a webbrowser and it will work i guess.

but i need to get some information from that string and not show it in a web browser.
What about using it in another language. Like english?
this is an option but then i need to translate everything to Hebrew and that can be very complicated.
Edit: You maybe can use jsoup (there is a library) to get the plain-text (html entities are converted).
thanx i will check! :)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
ok after many tries i could not get the result i want. i was able to load the text to a webview and then read the webview content and parse it back to a map but it is too complicated and also did not give me the solution i want.

all i want is get the information from the rss as a string i can show in my app.

this is a news rss example: http://www.ynet.co.il/Integration/StoryRss2.xml

i just dont understand how to read from it text i can use.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
test: xml2jon and xmlbuilder
B4X:
Public Sub TestAPIGetRSS

'    Dim BaseURL As String = "https://ims.gov.il/sites/default/files/ims_data/rss/alert/rssAlert_general_country_he.xml"
    Dim BaseURL As String = "http://www.ynet.co.il/Integration/StoryRss2.xml"
       
    Wait For (APIGetRSS(BaseURL)) Complete (Result As String)
    If Result.Length = 0 Then Return
   
    Dim xml As Xml2Map
    xml.Initialize
    Dim ParsedData As Map = xml.Parse(Result)
    TextArea1.Text = ParsedData.As(JSON).ToString
   
End Sub


Public Sub APIGetRSS(URL As String) As ResumableSub
    Dim ResultURL As String
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.Download(URL)
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            ResultURL = j.GetString
        End If
    Catch
        Log(LastException.Message)
    End Try
    j.Release
    Return ResultURL
End Sub

Json:

1635942236035.png


parse:

1635942425103.png
 
Upvote 1
Solution

ilan

Expert
Licensed User
Longtime User
test: xml2jon and xmlbuilder
B4X:
Public Sub TestAPIGetRSS

'    Dim BaseURL As String = "https://ims.gov.il/sites/default/files/ims_data/rss/alert/rssAlert_general_country_he.xml"
    Dim BaseURL As String = "http://www.ynet.co.il/Integration/StoryRss2.xml"
      
    Wait For (APIGetRSS(BaseURL)) Complete (Result As String)
    If Result.Length = 0 Then Return
  
    Dim xml As Xml2Map
    xml.Initialize
    Dim ParsedData As Map = xml.Parse(Result)
    TextArea1.Text = ParsedData.As(JSON).ToString
  
End Sub


Public Sub APIGetRSS(URL As String) As ResumableSub
    Dim ResultURL As String
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.Download(URL)
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            ResultURL = j.GetString
        End If
    Catch
        Log(LastException.Message)
    End Try
    j.Release
    Return ResultURL
End Sub

Json:

View attachment 121154

parse:

View attachment 121155

Thank you so much!!! ? ? ? ?

now i have something i can work with.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
for remove html tag:

1635944125591.png

see:
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
or use regex to filter HTML tags

I saw that you like to use regular expressions.


??????
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
I saw that you like to use regular expressions.

i like Regex but don't really know how to use it. i will watch again the video i have posted there. i think it is a must for every developer. even if it is just the basic it can really help in a lot of projects.
 
Upvote 0
Top