1

I want to add XML code in -NET C# XML documentation, i found this help: https://stackoverflow.com/a/11030588/2825284 but not work

        /// <summary>
        /// My comentary:
        /// <code>
        ///     <MyXmlCode>
        ///         <XmlNode Atribute="34"/>
        ///     </MyXmlCode>
        /// </code>
        /// </summary>

1 Answer 1

1

Your example code contains reserved XML characters that need to be escaped. These characters and their escape sequences are:

< ... &lt;
> ... &gt;
& ... &amp;

So your comment needs to be:

        /// <summary>
        /// My comentary:
        /// <code>
        ///     &lt;MyXmlCode&gt;
        ///         &lt;XmlNode Atribute="34"/&gt;
        ///     &lt;/MyXmlCode&gt;
        /// </code>
        /// </summary>

Or, to make it more readable, use CDATA:

        /// <summary>
        /// My comentary:
        /// <code><![CDATA[
        ///     <MyXmlCode>
        ///         <XmlNode Atribute="34"/>
        ///     </MyXmlCode>
        /// ]]></code>
        /// </summary>

BTW, our VSdocman contains the comment editor which produces CDATA. One drawback of CDATA is that Intellisense doesn't show it currently.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Peter Macej

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.