Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't XML allow nesting of comments

Tags:

xml

Is there any particular reason (other than it would make the parsing harder) that XML doesn't allow nesting comments, i.e. something like

<!--
  <!-- this is the foo element -->
  <foo>bar</foo>
-->

?

like image 929
helpermethod Avatar asked Mar 17 '26 09:03

helpermethod


1 Answers

It would have been entirely possible to allow nested comments, without changing the syntax. The designers of XML chose not to because they were greatly concerned with SGML compatibility: it would have allowed XML documents that were not valid SGML documents.

like image 130
Michael Kay Avatar answered Mar 18 '26 21:03

Michael Kay