Home > Articles

  • Print
  • + Share This

Error Messages

Parsers produce error messages that are often confusing. XML parsers are written with compiler technology. Consequently error messages are similar to what you should expect from a compiler: helpful but they rarely find the real error. If you have problems using parsers, an XML editor may help. The best XML editors provide extra guidance about errors which makes it easier to fix them.

In the best case, the error message points to the problem. For example, given the following fragment:

<p>Send comments and suggestions to <url protocol="mailto">

The parser generates an error message similar to this (the exact message depends on your parser):

</url> expected

And it is correct. The fragment misses an </url> closing tag.

Unfortunately, the error message can be very confusing. Given the following fragment

<p>Send comments and suggestions to <url protocol="mailto>

the parser generates two error messages:

attribute value must not contain '<'
"</p>" expected

However, these error messages are incorrect. The real problem is that the attribute has no closing quote. The correct message should have been:

" expected.

Instead the parser thinks that the attribute continues until the end of the line. When it reaches the end of the line, the parser is confused and it misses the p closing tag.

As you can see, it's important to take error messages with a pinch of salt.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.