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
1
: 916 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

<book>
<?ignore
  <author>
    <name>john</name>
  </author>
?>
</book>

Method 2:

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

<!-- 
 <data>
        <data-field1></data-field1>
        <data-field2></data-field2>
        <data-field3></data-field3>
 </data>
-->

Thanks.

1
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
Or
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