Reading XML and weird chars

I am reading data from an XML file into an array.
The XML has the following header

<?xml version="1.0" encoding="iso-8859-1"?>

Some chars with accent in the data as “Ros”, “Itali” are shown as weird characters.
I had the same problem a few months ago, reading data from a csv file, and could solve the problem by using the following code

if myFile <> Nil then
    t = TextInputStream.Open(myFile)
    t.Encoding=Encodings.MacRoman
    While Not t.EOF
      Mijndb.SQLExecute("BEGIN TRANSACTION")
      sLijn=t.ReadLine
      sLijn = ConvertEncoding(sLijn,Encodings.UTF8)
      aSamenstelling = Split(sLijn,";")
            MijnRec.Column("art_code")=aSamenstelling(0)
            MijnRec.Column("art_omschrijving")=aSamenstelling(1)
            MijnRec.Column("art_leverancier")=aSamenstelling(3)
            MijnDb.InsertRecord("artikels",MijnRec)
        If MijnDb.Error Then
          MsgBox MijnDb.ErrorMessage + " " + aSamenstelling(0) + "  " + aSamenstelling(1)
        Else
          ProgressBar1.Value=ProgressBar1.Value+1
        End If
        tmpRecordset.Close
    Wend
    Mijndb.Commit
  End If

But this doesn’t work this time.
Is encoding of the xml the reason?

How can i solve this problem?
By using an other encoding?

You could solve it by reading the file into an XMLDocument and extracting the elements that way. Any reason you chose not to do that?

And iso-8859-1 is ISOLatin1, not MacRoman.

You could solve it by reading the file into an XMLDocument and extracting the elements that way.

I tried but have the following error.
Current Line Number 1
Error Number 2
Message syntax Error.

Using ISOLatin1 is the solution!! Thanks.

Where can I find any documentation on this subject.

I Googled it. :slight_smile:

Look into the GetInternetTextEncoding function. Also, in the M_String package on my web site, there is a module to help deal with Encodings. Some methods are GetInternetTextEncodingFuzzy (attempts to get the right encoding even if the name is a bit off), ByAnalysis (examines the string and returns an encoding that seems to fit), and more.