Android Question Help with Xmlsax library and image download with map

samikinikar

Member
Licensed User
Longtime User
Can someone help with a example of image downloading along with XML contents, My basic requirements is display the listview with the correct thumbnail,title and the abstract,
I am able to get the title and the abstract with the examples given here (https://www.b4x.com/android/forum/threads/xml-parsing-with-the-xmlsax-library.6866/) with this library but not the images.

Also if possible, after click on the image or title in the listview, the detail view( the whole content of the abstract) to be displayed., right now the example opens the browser to display the content or image.

MyXML file is attached.
 

Attachments

  • myxml.xml
    67.3 KB · Views: 272

samikinikar

Member
Licensed User
Longtime User
Thank you so much for the update, I dont need the complete project, I just need the image downloading part in map.

I am able to see the output with the title and abstract but not with the images, so I only need the image part.

I am stuck in the following code

B4X:
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
    If parser.Parents.IndexOf("article_info") > -1 Then
        If Name = "title" Then
            Title = Text.ToString
     
         Else If Name = "abstract" Then
             abstract = Text.ToString
         Else if Name = "thumb" Then       
                 thumb=Text.ToString'
                  Dim job4 As HttpJob
          
           Dim out As OutputStream
            job4.Initialize("thumb",Me)
            job4.Download(thumb)
        End If
    End If
    If Name = "article_info" Then
        
       ListView1.AddTwoLinesAndBitmap(abstract,Title,job4.GetBitmap)
    End If
End Sub
 
Upvote 0

samikinikar

Member
Licensed User
Longtime User
Oh sorry about that, well with the help of your code only I have reached this level. now only I need to extract the text from the <image> tag from my XML file
Each time m is returning false. Following is the code,
B4X:
Sub ParseMainPage(page As String)
     Dim m As Matcher = Regex.Matcher("<image>([^>]+)</image>", page)
   
    Do While m.Find
        links.Add(m.Group(1))
        Dim Job As HttpJob
        Job.Initialize("Image", Me)
        JobsIndex.Put(Job, links.Size - 1)
        Job.Download("http://www.mydomainonline.com/custom/domain_1/image_files/" & m.Group(1))
    Loop
    Dim images(links.Size) As Bitmap
    CallSubDelayed2(Main,"CreateItems", links)

End Sub
 
Upvote 0

samikinikar

Member
Licensed User
Longtime User
Its perfectly working now. Thank you so much for all your support.

B4X:
Sub ParseMainPage(page As String)
    Dim m As Matcher = Regex.Matcher("<image>([^>]+)</image>", page)

    Do While m.Find
        links.Add(m.Group(1))
        Dim Job As HttpJob
        Job.Initialize("Image", Me)
        JobsIndex.Put(Job, links.Size - 1)
        Job.Download(m.Group(1))
    Loop
    Dim images(links.Size) As Bitmap
    CallSubDelayed2(Main,"CreateItems", links)

End Sub

Thank you once again for making me think over it again and again and get the problem solved.
 
Upvote 0
Top