How to dynamically insert a comment in an xml file

I have a simple task of adding a comment at the beginning of the line of xml file, where a specified latin letter is found.
Now i have been doing this manually, but I’m pretty sure there must be a better way of doing this. To more clearly explain:

existing line of code:
<xs:pattern value=“(||[\?]){1}”/>

needs to be
<!-- changed line –> <xs:pattern value=“(||[\?]){1}”/>

The comments have to be added to those lines in the file that contain the X in it, so how do i dynamically add a comment to at the beginning of those lines.

I can only think of using PHP for this since I’m new to pretty much everthing else, but what do the experts say?

Thanks

you could try using ‘sed’. It doesn’t have an idea about XML, but does it really need to know?

also this is in the Java forum… are you looking for a Java based solution?

It’s an xml file, so I figure java would be the way to go, somehow. Thanks