Give line number and column number of error instead of single location value on parse error
Bellarmine-Head opened this issue · comments
Bellarmine Head commented
This:-
fn main() {
let xml = r#"<?xml version="1.0"?>
<bookshop>
<books>
<book>
<title>The Illuminatus Trilogy</title>
</book>
</books>
</bookshop1>"#;
let result = parser::parse(xml);
match result {
Ok(_) => println!("parsed ok"),
Err((loc, errors)) => println!("parse failed; location = {}, errors = {:?}",
loc, errors),
}
}
will print:-
parse failed; location = 124, errors = [MismatchedElementEndName]
It would be nicer to give the line number and column number of the error, as all other XML parsers I've played with do.
Jake Goulding commented
Yep. Even better would be to copy what my other parser does and calculate the line / column and show a snippet.