Skip to content

Impossible to get parser errors #142

@twoellert-bipro

Description

@twoellert-bipro

Hey,

I am using libxml crate v0.3.3 and I am currently parsing a received string using the "parse_string_with_options" function of the Parser.
I have set the parser options to be fully pedantic about errors and show the errors and warnings.

`
let mut parser = Parser::default();

    // Set strict parsing options
    let mut parser_options = ParserOptions::default();
    parser_options.recover = false;
    parser_options.no_def_dtd = true;
    parser_options.no_error = false;
    parser_options.no_warning = false;
    parser_options.pedantic = true;
    
    debug!("Parsing XML document");
    let doc = parser.parse_string_with_options(body, parser_options)
        .map_err(|e: XmlParseError| {
            ConverterError::ValidationError(format!("XML parsing error: {}", e.to_string()))
        })?;

`

I then tested with an XML where the closing tag has a syntax error and is not matching the opening tag.

The error is shown in the text output on the command line but I see no way of getting the error reported back in my rust code.

Entity: line 29: parser error : Opening and ending tag mismatch: TestID line 29 and TestI <abc:TestID>FancyTest</abc:TestI>

The only error output I get from XmlParseError is "Got a Null pointer" from within the rust libxml code.

I know from C-times that libxml has some sort of weird generalized error handler but I also see no way to access this error handler via libxml in rust.

Any ideas or am I missing something obvious?

Thanks for any help!

Tom

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions