Skip to content

Instantly share code, notes, and snippets.

@dwarring
Created February 3, 2022 05:16
Show Gist options
  • Save dwarring/a3daec03cfb34b4dfcd61cd350a89de3 to your computer and use it in GitHub Desktop.
Save dwarring/a3daec03cfb34b4dfcd61cd350a89de3 to your computer and use it in GitHub Desktop.
use LibXML::Raw;
use LibXML::Parser::Context;
my $raw = xmlMemoryParserCtxt.new: :string<foo>;
my LibXML::Parser::Context $*XML-CONTEXT .= new: :$raw;
sub structured-error-cb($ctx, xmlError:D $err) {
$*XML-CONTEXT.structured-error($err);
}
$*XML-CONTEXT.raw.SetStructuredErrorFunc: &structured-error-cb;
for 1..250 {
$raw.ParseDocument;
try { $*XML-CONTEXT.flush-errors; }
}
warn "done";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment