xmlsax parsing problem

joe2236

Member
Licensed User
Longtime User
hi,

i am using the xmlsax 1.00 lib and having the following problem

my test xml generated with php

Code: Copy
<?php
  header("Content-Type: text/xml; charset=UTF-8");
  echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
  echo("<msgs>");
  echo("<text>".utf8_encode('äüöß')."</text>");
  echo("</msgs>");
?>

does create the following error in b4a

Code: Copy
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 61: unclosed token

i have traced this - this error only exists if i use non ascii chars.

when using ascii chars in the xml parsing works like expected.

any suggestions erel

:confused: joe
 
Last edited:
hi erel

attached the xml file (renamed to txt because of forum xml file upload not allowed)

greetings
joe
 

Attachments

I'm not getting any error with this code:
Code: Copy
Sub Process_Globals
    Dim parser As SaxParser
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
    parser.Initialize
    
    parser.Parse(File.OpenInput(File.DirAssets, "test.txt"), "parser")
End Sub
Sub parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
    Log(uri)
    Log(name)
End Sub
Sub parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
    Log(uri)
    Log(name)
    Log(text)
End Sub
 
ah found the problem

im getting the xml data from http

old code was
Code: Copy
Dim ret As String
Dim i As InputStream

ret=Response.GetString("UTF-8")
i.InitializeFromBytesArray(ret.GetBytes("UTF-8"),0,ret.Length)
parser.Initialize      
parser.Parse(i, "Parser")

new code now has no problems
Code: Copy
Dim ret As String
Dim i As InputStream

ret=Response.GetString("UTF-8")
i.InitializeFromBytesArray(ret.GetBytes("UTF-8"),0,ret.GetBytes("UTF-8").Length)
parser.Initialize      
parser.Parse(i, "Parser")

thanks and sorry for this - still learning

:sign0060: joe
 
Back
Top