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:

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:



parse:

 
Upvote 1
Solution

ilan

Expert
Licensed User
Longtime User

Thank you so much!!! ? ? ? ?

now i have something i can work with.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
for remove html tag:


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
Cookies are required to use this site. You must accept them to continue using the site. Learn more…