Android Question map question

tufanv

Expert
Licensed User
Longtime User
Hello

In my list i have
B4X:
    "NSMapTable {\n[1] Last -> 03:37:14\n[2] Ask -> 1.22961\n[3] High -> 1.2365\n[9] Attributes -> (read only map) {\n    Symbol = GBPUSD;\n}\n[10] Bid -> 1.22928\n[12] Low -> 1.22886\n[15] Direction -> -1\n}\n",

With :

B4X:
    For Each item As Map In m2
        Dim title As String = item.Get("Bid")
        Dim link As String = item.Get("Ask")
    Next

I can get bid and ask values but i cant get the symbol value. Symbol is different from other it has a = instead of ->
How can i get the Symbol value here ?

BTW : normally the data is like this :
B4X:
<Rates>
<Rate Symbol="EURUSD">
<Bid>1.05154</Bid>
<Ask>1.05179</Ask>
<High>1.05765</High>
<Low>1.04796</Low>
<Direction>-1</Direction>
<Last>03:38:55</Last>
</Rate>

I use this code to get bid and ask but i cant get the symbol

B4X:
Dim xm As Xml2Map
            xm.Initialize
            ParsedData = xm.Parse(File.ReadString(File.DirTemp, "ratesxml2.xml"))
            'Log(ParsedData)
            Dim m1 As Map = ParsedData.Get("Rates")
            LogColor(m1,Colors.blue)
            Dim m2 As List
            m2 = m1.Get("Rate")
            Log(m2)
   

            For Each item As Map In m2
                Dim title As String = item.Get("Bid")
                Dim link As String = item.Get("Ask")
                Log(title & link)
            Next

Thanks
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
I had missed the part that there is an attributes map inside it so i changed the code to:
B4X:
            For Each item As Map In m2
                Dim title As String = item.Get("Bid")
                Dim link As Map = item.Get("Attributes")
                Dim sik As String = link.Get("Symbol")
                Log(title & sik)
            Next

and it worked
 
Upvote 0
Top