Include XML in XML comments?

  • Thread starter Thread starter Marty McDonald
  • Start date Start date
M

Marty McDonald

In my C# code, I'm using the <code> ... </code> tags. Within those tags,
I'm trying to show what the app's config file should look like. That means
I'm trying to put XML into those tags! But of course I don't want them
processed by any documentation generators. Is there a way to specify
comments that should be output as-is? Thanks! Marty
 
writing &gt / &lt instead of < and >?

If the end-result is HTML, this should produce correct results.

Niki
 
Marty McDonald said:
In my C# code, I'm using the <code> ... </code> tags. Within those tags,
I'm trying to show what the app's config file should look like. That means
I'm trying to put XML into those tags! But of course I don't want them
processed by any documentation generators. Is there a way to specify
comments that should be output as-is? Thanks! Marty

You can stick your XML inside of CDATA tags like:

<code>
<![CDATA[ <?xml version="1.0"> ...rest of your xml goes here... ]]>
</code>

The only caveat here is you have to make sure that you do not use CDATA tags
inside of your XML... if so, you have to mangle the end part of the tag
(i.e. the ]]> part) so that your outside CDATA tag doesn't terminate
early... I normally inject a space to do that and put a warning at the end
of the code section that I have done that - just in case someone cut and
pastes the xml.

This has always worked for me... HTHs...

John
 
Thanks both of you for the replies. I'm using the CDATA tags as John
suggested and that works best for my situation. I'm using NDOC, and things
are working great now.
 
Back
Top