B4J Question how to read this xml file?

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hello everybody
can someone tell me with which library I can read the attached file, which I cannot read with the libraries (xml sax and xmlmap)

Here is example

B4X:
Dim aIS As InputStream = File.OpenInput(File.DirAssets,"county.xml")
    
    TR.Initialize(aIS)
    
'    TR.Initialize(File.OpenInput(File.DirAssets,"county.xml"))
    xml.Initialize
    xml.Parse2(TR,"Parser")





thank in advance
 

Attachments

  • county.xml
    16.6 KB · Views: 151

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
best xml library for me is this one:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Works fine here, tested with this code:
B4X:
Sub AppStart (Args() As String)
    Dim x2m As Xml2Map
    x2m.Initialize
    Dim s As String = File.ReadString("C:\Users\H\Downloads\county.xml", "")
    Dim m As Map = x2m.Parse(s)
    Log(m.As(JSON).ToString)
End Sub
Note that the file starts with UTF8 BOM. This is a big mistake though it didn't cause any error when I test it.
You can remove the BOM character with:
B4X:
s = s.Substring(1)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…