0

I receive an error with incoming XML going through my WebAPI into the parser. I expect an error due to passing in a parameter as a wrong data type, but the row and character numbers are wrong in this error message: There is an error in XML document (2, 11).

I tried searching for wrong numbers in the XML Parser error message. All talk about what to do with the message but couldn't find any about getting wrong numbers.

I would expect it to be this: There is an error in XML document (27, 20).

What causes the default .Net Framework 4.7.2 XmlSerializer to give the wrong numbers?

This makes the user look into row 2 and they don't understand why that line is the problem.

  • It is possible that you've found a bug, but it is much more likely that you do not fully understand how the parser works. In general, syntax checkers point to the spot where they first see a problem, which can be past the actual code bug or invalid data. That's all I can see without a Minimal Reproducible Example, see How to Ask - https://stackoverflow.com/help/how-to-ask – Dave S Jul 10 '23 at 21:52
  • @DaveS When I fix row 27 the XML Parser works. The only logical thing I can think of is just throws up and gives me the root element in the error message. – user21908362 Jul 10 '23 at 22:07
  • There's no way for us to say unless you edit your question to add the XML (as text not an image or link - see How to Ask above). For a MRE you could trim any earlier records or optional tags. Creating a MRE might also help you spot anything you're missing. – Dave S Jul 10 '23 at 22:10

0 Answers0