Ok I got it worked but I think there is still something wrong.
Here is the code that didn't work
B4X:
Dim XOMBuilder1 As XOMBuilder
XOMBuilder1.Initialize("XOMBuilder1")
XOMBuilder1.BuildFromFile(File.DirDefaultExternal & "\connections.xml",Null)
Here is the code that works
B4X:
Dim bufstr As String
bufstr=File.ReadString(File.DirDefaultExternal, "connections.xml")
Dim XOMBuilder1 As XOMBuilder
XOMBuilder1.Initialize("XOMBuilder1")
XOMBuilder1.BuildFromString(bufstr, "", Null)
By the way the file I am reading is downloaded from an FTP server.
What do you mean by but I think there is still something wrong?
Does the BuildDone event get raised and passed a valid XOMDocument object?
Is the XOMDocument not quite right - does it look as though your XML has not been correctly parsed?
If so is it a character encoding problem?
Have you tried the XOMBuilder BuildFromURL method - does it retrive the XML from your FTP server (don't forget you'll need to add the permission android.permission.INTERNET to your project if it is not already added in order to use this method).
In your XOMBuilder BuildDone event Sub you can now get the text of any exception that occurred while trying to build the XOMDocument:
B4X:
Sub XOMBuilder1_BuildDone(XOMDocument1 As XOMDocument, Tag As Object)
If XOMDocument1=Null Then
' XOMDocument1 will be Null if an error has occurred
Log("An error has occured and the XOMDocument has NOT been created")
Log(LastException)
Else
Log("XOMDocument is NOT Null")
' proceed to work with the XOMDocument
End If
End Sub
Hopefully the text of the exception will throw some light on what's going wrong here.
When I try the code I got (FileNotFoundException) java.io.FileNotFoundException: /mnt/sdcard/Android/data/b4a.example/files\connections.xml (No such file or directory)
which was my mistake to use "\" instead of "/".
Sorry I took your time. May be you consider auto correcting path separator char.
Combine (Dir As String, FileName As String) As String
Returns the full path to the given file.
This methods does not support files in the assets folder.