8000 Stream fails to parse if XML file contains a leading BOM character · Issue #117 · qcam/saxy · GitHub
[go: up one dir, main page]

Skip to content

Stream fails to parse if XML file contains a leading BOM character #117

Open

Description

@edds

If an XML file contains a leading BOM Saxy fails to parse the file.

iex(1)> xml = "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"><foo bar='value'></foo>"
iex(2)> Saxy.parse_string(data, MyEventHandler, [])
"Start parsing document"
{:error,
%Saxy.ParseError{
  reason: {:token, :lt},
  binary: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"><foo bar='value'></foo>",
  position: 0
}}

I'm seeing this when using ExCmd to stream a gziped file into Saxy and can't see any obvious way of stripping it out before passing the stream to Saxy.

Activity

  1. lucacorti commented on Feb 28, 2024

    @lucacorti
    Contributor

    Yes, this happens. You can use String.replace_leading(xml, "\uFEFF", "") to strip the BOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0