Suzan Cioc
Suzan Cioc

Reputation: 30147

Putting sample XML code in Javadoc

How to put a sample XML code in Javadoc? The XML code includes angle brackets which I do not want to be processed.

I tried combinations of PRE and code but it didn't work.

Upvotes: 16

Views: 6794

Answers (2)

troig
troig

Reputation: 7212

You can use @code javadoc tag. Take a look to this post, wich contains some examples. Hope it helps

/**
 * To use this class use this XML   
 * <pre>
 * {@code
 * <xml>
 *   <parameter>foo</parameter>
 *   <value>bar</value>
 * </xml>
 * }
 * </pre>
 */

Upvotes: 30

Andy
Andy

Reputation: 1994

You have to use HTML/XML encoding like &lt; for < and &gt; for >.

If you use Eclipse, there is a Javadoc view that shows you a preview.

Upvotes: 6

Related Questions