version 4.5.0
Not logged in

Back to main SpatiaLite-Tools Wiki page


spatialite_xml2utf8

All spatialite-tools importing data from XML files are based on the very popular expat XML parser. As it emerged by practical experience, this parser isn't directly able to correctly handle XML documents adopting any character set different from UTF-8. When attempting to import any non-utf8 encoded XML file "invalid character" errors could eventually be reported. The new spatialite_xml2utf8 CLI tool is specifically intended to circumvent such a limitation in the easiest way.

a practical example

Supposing some XML document starting with a first line like:
<?xml version="1.0" encoding="windows-1252" ?>
...
or
<?xml version="1.0" encoding="ISO-8859-1" ?>
...
Such an XML file clearly adopts some character set different from UTF-8, and could easily cause the parser to complain about "invalid character" errors:
Resolving this issue is basically simple; you just have to execute spatialite_xml2utf8 so to get a copy of the XML file correctly encoded as UTF-8:
spatialite_xml2utf8 CP1252 <old.xml >new.xml



Back to main SpatiaLite-Tools Wiki page