Hello All!
I seem to be stuck with a problem on parsing a simple xml file - the xml sax parser returns a null pointer exception.
the xml file is languages.xml and is in the follow format:
it is saved as a UTF-8 encoded file, and then copied from dir assets to the default external directory at runtime.
Next, I initialize the input stream, and begin parsing..
I know the file is opened, because as you can see below, there are bytes available... but here is what the logs show...
any help would be greatly appreciated.
...Pablo
I seem to be stuck with a problem on parsing a simple xml file - the xml sax parser returns a null pointer exception.
the xml file is languages.xml and is in the follow format:
B4X:
<?xml version="1.0" encoding="UTF8"?>
<listing>
<language>
<number>0</number>
<name>Engish</name>
<abbrev>en</abbrev>
<backbreak>false</backbreak>
<vod>Verse of the Day</vod>
<imgfile>us-48.png</imgfile>
</language>
<language>
<number>1</number>
<name>Spanish</name>
<abbrev>es</abbrev>
<backbreak>false</backbreak>
<vod>Verso del Dia</vod>
<imgfile>us-48.png</imgfile>
</language>
<language>
<number>2</number>
<name>Portuguese</name>
<abbrev>pt</abbrev>
<backbreak>false</backbreak>
<vod>Versículo do Dia</vod>
<imgfile>pt-48.png</imgfile>
</language>
</listing>
it is saved as a UTF-8 encoded file, and then copied from dir assets to the default external directory at runtime.
Next, I initialize the input stream, and begin parsing..
B4X:
Sub Carga_Idiomas
Dim In As InputStream
'Try
In = File.OpenInput(File.DirDefaultExternal,"languages.xml")
If In.IsInitialized=True Then 'puedo acceder??
Log("está abierto!") 'sip
Log("Bytes disponsible: " & In.BytesAvailable)
End If
Parser.Parse(In, "Parser")
In.Close
'Catch
Log("languages.xml esta dañado")
'End Try
End Sub
I know the file is opened, because as you can see below, there are bytes available... but here is what the logs show...
B4X:
está abierto!
Bytes disponsible: 619
vod_svc_carga_idiomas (java line: 133)
java.lang.NullPointerException
at anywheresoftware.b4a.objects.SaxParser.parse(SaxParser.java:76)
at anywheresoftware.b4a.objects.SaxParser.Parse(SaxParser.java:71)
at com.ifn.vod.vod_svc._carga_idiomas(vod_svc.java:133)
at com.ifn.vod.vod_svc._service_create(vod_svc.java:432)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
at com.ifn.vod.vod_svc.onCreate(vod_svc.java:42)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2253)
at android.app.ActivityThread.access$1600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Unable to create service com.ifn.vod.vod_svc: java.lang.RuntimeException: java.lang.NullPointerException
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2263)
at android.app.ActivityThread.access$1600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:193)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
at com.ifn.vod.vod_svc.onCreate(vod_svc.java:42)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2253)
... 10 more
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.objects.SaxParser.parse(SaxParser.java:76)
at anywheresoftware.b4a.objects.SaxParser.Parse(SaxParser.java:71)
at com.ifn.vod.vod_svc._carga_idiomas(vod_svc.java:133)
at com.ifn.vod.vod_svc._service_create(vod_svc.java:432)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
... 13 more
any help would be greatly appreciated.
...Pablo