Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested comments in XML?

Tags:

comments

xml

Are these nested comments allowed in a XML file?

<!-- Making only one observation attempting to correct the error code --> <!-- <component>        <!-- Result observation template -->             <!-- <id root="2.16.840.1.113883.19.5.10" extension="103220"/>      </component> --> 
like image 460
Laxmikanth Samudrala Avatar asked Aug 24 '09 21:08

Laxmikanth Samudrala


2 Answers

No, the string -- is not permitted to appear within comments in XML. So the fact you have -- show up inside another comment is going to cause failures.

And trying to post that answer also broke the text entry parsing ;)

For further proof, check the W3C specification:

http://www.w3.org/TR/2008/REC-xml-20081126/#sec-comments

The phrase

For compatibility, the string " -- " (double-hyphen) MUST NOT occur within comments.]

appears in the first paragraph of the section on XML comments.

like image 184
Brent Writes Code Avatar answered Sep 28 '22 06:09

Brent Writes Code


As it is said in How do I comment out a block of tags in XML?, you can try to wrap your code with a non-existing processing-instruction, e.g.:

<?ignore <component>        <!-- Result observation template -->             <!-- <id root="2.16.840.1.113883.19.5.10" extension="103220"/>      </component>  ?> 
like image 45
psychoslave Avatar answered Sep 28 '22 06:09

psychoslave