B4J Question Making an XML file from a Map

Peter Lewis

Active Member
Licensed User
Longtime User
Hi

I have followed Erel's post
1642529270476.png

Which I have done

B4X:
Dim xmlb As XMLBuilder

in the Process Globals

But I cannot find the Map2Xml


Any Ideas ?

I want to make an import file for Filezilla as the internal FTP is VERY VERY slow and Filezilla is about 10 x faster while downloading

end Result:
<?xml version="1.0" encoding="UTF-8"?>
<FileZilla3 version="3.57.0" platform="windows">
    <Queue>
        <Server>
            <Host>ftp.vip****.name</Host>
            <Port>21</Port>
            <Protocol>0</Protocol>
            <Type>0</Type>
            <User>djpeter</User>
            <Pass encoding="base64">********=</Pass>
            <Logontype>1</Logontype>
            <PasvMode>MODE_PASSIVE</PasvMode>
            <MaximumMultipleConnections>5</MaximumMultipleConnections>
            <EncodingType>Auto</EncodingType>
            <BypassProxy>0</BypassProxy>
            <Name>musicftp new</Name>
            <File>
                <LocalFile>r:\16 nov music\Afro Beat\Ding Dong - Normal Pree (Dirty).mp3</LocalFile>
                <RemoteFile>Ding Dong - Normal Pree (Dirty).mp3</RemoteFile>
                <RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
                <Flags>16</Flags>
                <Size>6479995</Size>
            </File>
            <File>
                <LocalFile>r:\16 nov music\Afro Beat\CKay Ft. Blxckie - By Your Side (MMP Intro Edit) (Clean).mp3</LocalFile>
                <RemoteFile>CKay Ft. Blxckie - By Your Side (MMP Intro Edit) (Clean).mp3</RemoteFile>
                <RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
                <Flags>16</Flags>
                <Size>9732888</Size>
            </File>
            <File>
                <LocalFile>r:\16 nov music\Afro Beat\CKay - Emiliana (Clean).mp3</LocalFile>
                <RemoteFile>CKay - Emiliana (Clean).mp3</RemoteFile>
                <RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
                <Flags>16</Flags>
                <Size>7193548</Size>
            </File>
            <File>
                <LocalFile>r:\16 nov music\Afro Beat\CKay - Emiliana (MMP Intro Edit) (Clean).mp3</LocalFile>
                <RemoteFile>CKay - Emiliana (MMP Intro Edit) (Clean).mp3</RemoteFile>
                <RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
                <Flags>16</Flags>
                <Size>7120138</Size>
            </File>
            <File>
                <LocalFile>r:\16 nov music\Afro Beat\Goya Menor &amp; Nektunez - Ameno Amapiano [Remix] (MMP Intro Edit) (Dirty).mp3</LocalFile>
                <RemoteFile>Goya Menor &amp; Nektunez - Ameno Amapiano [Remix] (MMP Intro Edit) (Dirty).mp3</RemoteFile>
                <RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
                <Flags>16</Flags>
                <Size>10450209</Size>
            </File>

I have all the data in MSsql so it will be easy to make a map

Any ideas would be appreciated

Thank you
 

Peter Lewis

Active Member
Licensed User
Longtime User
Since I could not find that method, I solved it by doing this

B4X:
Sub makexml(listofmaps As List)
  
    Dim x As XMLBuilder
    x = x.create("Server").attribute("name", "Filezilla")
  For p = 0 To listofmaps.size-1
      Dim infomap As Map = listofmaps.Get(p)
                x = x.element("File") _
                    .element("LocalFile") _
                    .text(infomap.Get("LocalFile")) _
                    .up() _
                    .element("RemoteFile") _
                    .text(infomap.Get("RemoteFile")) _
                    .up() _
                     .element("RemotePath") _
                    .text(infomap.Get("RemotePath")) _
                    .up() _
                    .element("Flags") _
                    .text(infomap.Get("Flags")) _
                    .up() _
                    .element("Size") _
                   .text(infomap.Get("Size")) _
                    .up() _
                .up()
    Next
 
    Dim props As Map
    props.Initialize
    props.Put("{http://xml.apache.org/xslt}indent-amount", "4")
    props.Put("indent", "yes")
  
'    Log(x.asString2(props))
 
    File.WriteString("c:\temp", "filezilla.xml", x.asString2(props))
Log("Finished")
End Sub

But it seems like Filezilla does not like the Import of the data which is something I am going to have to check on.

Their Remote path looks like this
<RemotePath>1 0 4 2022 6 _01.22 17 17.01.22 - 50.8GB 9 Afro Beat</RemotePath>
Where mine is like this
<RemotePath>/2022/_01.22/17.01.22 - 50.8GB/Afro Beat</RemotePath>

********** UPDATE ***************

looking at another directory level added I have noticed a pattern emerging

<RemotePath>1 0 4 2022 6 _01.22 18 18.01.22 - 114.8GB 34 VA - W9 Hits 2022 (4CD) (2022) Mp3 3 Cd3</RemotePath>

The 1 0 at the begin I cannot explain but seems like it is the same for any of the download Queue

4 Is the Length of the next part of the path '2022'
6 Is the Length of the next part of the path '_01.22'
18 Is the Length of the next part of the path '18.01.22 - 114.8GB'
34 Is the Length of the next part of the path 'VA - W9 Hits 2022 (4CD) (2022) Mp3'
3 Is the Length of the next part of the path 'Cd3'
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
The 1 0 at the begin I cannot explain but seems like it is the same for any of the download Queue

The 1 0 might be a nullish string to force a (presumably optional) leading /

Or it might be an index number (to handle multiple paths or downloads) or a protocol number (eg 0 = http:// 2 = ftp:// 3 = https:// ???) or a device number.
 
Last edited:
Upvote 0
Top