Skip to content

Encoding Error ISO-8859-1 SimpleForm #85

Description

@blackode

XML String

data = "<?xml version='1.0' encoding='ISO-8859-1'?><OTA_HotelAvailRS xmlns=\"http://parsec.es/hotelapi/OTA2014Compact\" TimeStamp=\"2021-03-17T08:56:29Z\" PrimaryLangID=\"en-GB\" Id=\"11,33667649,72545\"><Hotels HotelCount=\"0\"><DateRange Start=\"2021-04-20\" End=\"2021-04-21\" /><RoomCandidates><RoomCandidate RPH=\"0\"><Guests><Guest AgeCode=\"A\" Count=\"2\" /></Guests></RoomCandidate></RoomCandidates></Hotels></OTA_HotelAvailRS>"

Here, the encoding value is ISO-8859-1.

Now, if I try run simple form it is giving me the following error

Error

iex(12)> Saxy.SimpleForm.parse_string(data)
{:error,
 %Saxy.ParseError{
   binary: "<?xml version='1.0' encoding='ISO-8859-1'?><OTA_HotelAvailRS xmlns=\"http://parsec.es/hotelapi/OTA2014Compact\" TimeStamp=\"2021-03-17T08:56:29Z\" PrimaryLangID=\"en-GB\" Id=\"11,33667649,72545\"><Hotels HotelCount=\"0\"><DateRange Start=\"2021-04-20\" End=\"2021-04-21\" /><RoomCandidates><RoomCandidate RPH=\"0\"><Guests><Guest AgeCode=\"A\" Count=\"2\" /></Guests></RoomCandidate></RoomCandidates></Hotels></OTA_HotelAvailRS>",
   position: 30,
   reason: {:invalid_encoding, "ISO-8859-1"}
 }}

I tried to replace ISO-8859-1 with 'UTF-8' and it is working fine.

Is there a way to parse ISO-8859-1 encoded xml?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions