tags:

views:

810

answers:

3

is this allowed nested comment in the 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> -->
+2  A: 

You can't. -- both starts and terminates a comment. This makes nesting them impossible.

David Dorward
+1  A: 

In a word - no.

The first encountered end-comment marker will, er... end the comment and the rest of it will look somewhat unpleasant from there on out.

annakata
+10  A: 

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.

Brent Nash
<!-- this is not true -- or is it? -->
annakata
<!-- *it* -- is an error --> System.Xml.XmlException: This is an invalid comment syntax.
bill weaver
but WHY?!!!!!!!
zvolkov
It's to ensure compatibility with SGML.
Brent Nash