How to use comments in XML document

You can also add comments to an XML document. Comments go just about anywhere and are ignored  for data processing purposes. Comments are bracketed by the <!– and –> character sequences. The following listing includes three valid comments:

C# in Depth, 3rd EditionManaged Windows VPS Hosting


<?xml version=”1.0″?>


<!– This is an example . –>

<Book ISBN-13=” 978-0545139700” Title = Title>Harry Potter and the Deathly Hallows“>

<Author>J.K. Rowling</Author>




<Book ISBN-13=”978-1451648539” Title=”Steve Jobs”>

<Author>Walter Isaacson</Author>


<Available>False <!– Why isn’t available ? –> </Available>


<!– Other books omitted for clarity. –>


The only place you can’t put a comment is embedded within a start or end tag (as in <myData <!– A comment should not go here –></myData>).