Came across such scenario recently where had to remove all the comments from XML file before processing it through grep, sed, awk and other bash shell utilities.
Sed proved to be a handy tool to remove all the single and multiline comments from the XML files.
Sample XML file. [Assuming filename as sample.xml]
<?xml version="1.0" encoding="ISO-8859-1"?>Command below would be able to remove all the comments in the sample.xml file
If the message tag does not contain a definition of a property,
the default value will be used.
<!-- some comment -->
<!-- another comment -->
This is another multiline comment.
$ cat sample| sed '/<!--.*-->/d'| sed '/<!--/,/-->/d'
<?xml version="1.0" encoding="ISO-8859-1"?>Cheers,
make world open.