How to add comments in XML?

I am working XML document recently, I am thinking to add comments in some section of XML document, so I would like to know easy way to add comments in XML Document.

Asked by:- Vinnu
: 676 At:- 1/1/2023 9:11:46 AM
XML add comments in XML

1 Answers
profileImage Answered by:- vikas_jk

There are few ways to add comments in XML:

Method 1:

You can wrap the text with a non-existing processing-instruction as shown below


Method 2:

Use the <!--...--> format to add comments, which is similar to comment in HTML doc:



At:- 1/1/2023 9:16:23 AM
Method 2 to add comments in XML looks simpler to me, thanks. 0
By : Vinnu - at :- 1/1/2023 9:17:16 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly