Commenting xml file lines

Hi ,

I have a XML file like this

<

dependency>
      <groupId>fr.xxxx.portail.ear</groupId>
      <artifactId>_xxxEAR</artifactId>
      <version>1.0.0-20xxxxx.xxxxx-x</version>
      <type>ear</type>
    </dependency>

I need to comment single/multiple lines from XML file.
How can i comment using (<-- and -->) , if i want to comment <dependency> tag (allthe 6 lines) and for
<groupId> tag (only one line)

Can any one help me in this .... ?
Thanks in advance ....

Something like this?

sed '/<dependency>/s/^/<--/;/<\/dependency>/s/$/-->/' inputfile > outputfile
sed '/<groupId>/s/\(.*\)/<--\1-->/' inputfile > outputfile

Do you want to comment out the contents of the field, or the start and end tags too?

If the file is regularly formatted, the sed scripts by Annihilannic will work (perhaps with some minor modifications if you want to keep the start and end tags and just comment out the contents). If the file is free-form, perhaps you should look into XSLT.

Don't you comment xml using <!-- and -->

Hi All,

Annihilannic solution worked perfectly ...

Thanks all

Thanks and Regards,
Scorpio

it works for a file where the start tags are unique... but wht if the tags are same?
something like the one as below and i hv 2 comment tag with content mno?
<Service>
<name>abc</name>
</Service>
<Service>
<name>mno</name>
</Service>
<Service>
<name>xyz</name>
</Service>

That's a much simpler problem than the original question; you know exactly what you're searching for so it's just a search and replace. What have you tried and in what way did it fail?