Include XML in XML comments?

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
 
N

Niki Estner

writing &gt / &lt instead of < and >?

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

Niki
 
J

John Beyer

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
 
M

Marty McDonald

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top