Android Question xml2map 'enclosure' parse

Almora

Well-Known Member
Licensed User
Longtime User
I'm using the xml2 library.
I could not display the image file.
how can I show the image.

B4X:
 <enclosure type="image/jpg" length="63309" url="https://www.b4x.com/xx.jpg"/>

B4X:
 <item>
      <title>B4X</title>
      <description><![CDATA[Simple, powerful and modern development tools]]></description>
      <pubDate>Sun, 17 Feb 2019 20:00:00 +0300</pubDate>
      <link>https://www.b4x.com/</link>
      <guid>https://www.b4x.com/</guid>
      <enclosure type="image/jpg" length="63309" url="https://www.b4x.com/xx.jpg"/>
      <category><![CDATA[tools]]></category>
      <category><![CDATA[tools]]></category>
      <content:encoded><![CDATA[<strong>b4x.</content:encoded>
      <slash:comments>0</slash:comments>
    </item>
 
Last edited:

Almora

Well-Known Member
Licensed User
Longtime User
I can't get the image url with xml2map.
I can get the others.
B4X:
Dim rss As Map = ParsedData.Get("rss")
   Dim channel As Map = rss.Get("channel")
   Dim items As List = channel.Get("item")
   For Each item As Map In items
     Dim title As String = item.Get("title")
     Dim desc As String = desc.Get("description")
     Dim link As String = item.Get("link")

    Dim imageurl As String = item.Get("enclosure") ' ---?? image can't get url.
 '    Dim imageurl As String = item.Get("url") ' ---?? image can't get url.
      
     Label1.text=imageurl
   Next
 
Last edited:
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
B4X:
   If FirstTime Then
     Dim xm As Xml2Map
     xm.Initialize
     ParsedData = xm.Parse(File.ReadString(File.DirRootExternal, "rss.xml"))
   End If
   Activity.LoadLayout("2")
 
   Dim rss As Map = ParsedData.Get("rss")
   Dim channel As Map = rss.Get("channel")
   Dim items As List = channel.Get("item")
   For Each item As Map In items
     Dim title As String = item.Get("title")
    ' Dim link As String = item.Get("link")
    ' Dim desc As String = item.Get("description")
 
 
    Dim imageurl As String = item.Get("enclosure" &"url="&""&"lenght="&""&"type="&"image/jpeg")
     
     ListView1.AddSingleLine2(title,"")
     Label1.Text=imageurl
   Next

I can't get the image url..
imageurl= null
 

Attachments

  • layot2.jpg
    layot2.jpg
    62.5 KB · Views: 158
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim rss As Map = ParsedData.Get("rss")
    Dim channel As Map = rss.Get("channel")
    Dim items As List = channel.Get("item")
    For Each item As Map In items
        Dim title As String = item.Get("title")
        Log($"Item: ${item}"$)
        ' Dim link As String = item.Get("link")
        Dim desc As String = item.Get("description")
        Dim enclosure As Map = item.Get("enclosure")
        Log($"Enclosure: ${enclosure}"$)
        Dim Attributes As Map = enclosure.Get("Attributes")
        Log($"Attributes: ${Attributes}"$)
        Dim url As String = Attributes.Get("url")
      
    Next
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
thanks. works..
Log(rss)>>>>>I think it's not going to be understood .. sometimes:cool:o_O
 
Upvote 0
Top