[fpc-pascal] ReadXMLFile() fails reading a xml file

Michael Van Canneyt michael at freepascal.org
Tue Feb 2 09:38:50 CET 2010



On Tue, 2 Feb 2010, Graeme Geldenhuys wrote:

> Hi,
>
> Part of creating a new cross-platform installer application, I'm trying to
> read an XML file that contains UTF-8 characters, but I get the following
> error. Unicode support is very important, because the setup program must
> support multiple languages. Does this mean the XML implementation in FPC
> doesn't support Unicode enabled XML at all?  :-(

It does, but you must specify the codepage in the XML header of the file.

<?xml version="1.0" encoding="utf-8"?>

And you must of course make sure the contents match the header :-)

Michael.
>
>
>  // that reads the xml file
>  ReadXMLFile(doc, './setup.xml');   //  <<-- Fails on this line!
>  if not Assigned(doc) then
>    exit;
>
>
> ---------------------------------------------
> $ ./setup_gui
> DEBUG:  TMainForm.FormShow >>
> DEBUG:  TMainForm.PopulateInstallOptions >>
> An unhandled exception occurred at $000000000050E277 :
> EXMLReadError : In 'file:./setup.xml' (line 23 pos 20): Invalid character
> in input stream
>  $000000000050E277 line 1298 of src/xmlread.pp
>  $000000000050E12B line 1270 of src/xmlread.pp
>  $000000000050DF6E line 1252 of src/xmlread.pp
>  $00000000005161F4 line 3735 of src/xmlread.pp
>  $0000000000516361 line 3754 of src/xmlread.pp
>  $000000000046847B line 185 of frm_main.pas
>  $0000000000467DEE line 66 of frm_main.pas
>  $00000000004679DB line 350 of ../../gui/fpg_form.pas
>  $00000000004676D8 line 287 of ../../gui/fpg_form.pas
>  $000000000041D1CE line 22 of setup_gui.lpr
>  $000000000041D216 line 30 of setup_gui.lpr
> ---------------------------------------------
>
>
> Here is a snippet of the XML file I'm trying to read
> -------------[ setup.xml ]--------------------
> <?xml version="1.0" standalone="yes"?>
> <install product="SC3U" desc="SimCity 3000 Unlimited" version="2.0">
>  <readme>
>   README
>  </readme>
>  <readme lang="fr">
>   README.fr
>  </readme>
>  <readme lang="de">
>   README.de
>  </readme>
>  <readme lang="es">
>   README.es
>  </readme>
>  <readme lang="sv">
>   README.sv
>  </readme>
>  <option install="true" required="true">
>  Base Install
>  <lang lang="fr">Installation de base</lang>
>  <lang lang="sv">Basinstallation</lang>
>  <lang lang="it">Installazione Minima</lang>
>  <lang lang="es">Básica Instalación</lang>
>  <lang lang="de">Basisinstallation</lang>
>  <lang lang="nl">Basis-installatie</lang>
>  <help>Required for play</help>
>  <help lang="fr">Requis pour jouer</help>
>  <help lang="sv">Filer som behövs för att spela</help>
>  <help lang="it">Richieste Software</help>
>  <help lang="es">Requerido para el juego</help>
>  <help lang="de">Zum Spielen benötigt</help>
>  <help lang="nl">Vereist voor het spel</help>
> ...
> ----------------------------------------------
>
>
> Regards,
>  - Graeme -
>
> -- 
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://opensoft.homeip.net/fpgui/
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


More information about the fpc-pascal mailing list