Help with search and delete/add/modify script

Gurus,

I need to run a script on multiple XML files in different directories and do the following (the output can be redirected to create a new file)

  1. Search a pattern like "abc.mno.xyz" in an XML file, once detected, the script should delete one line above and 3 lines below (including the line containing the pattern)

So the following pattern should just disappear from the text file on which I will run this script

<option>
<name>abc.mno.xyz</name>
<value>true</value>
</option>

  1. Update the following fragment in the XML file

             &lt;options&gt;
               &lt;option&gt;
                  &lt;name&gt;addAllRoles&lt;/name&gt;
                  &lt;value&gt;true&lt;/value&gt;
               &lt;/option&gt;
            &lt;/options&gt;
    

to the following (it changes one of the value from true to false and adds an additional xml tag)

        &lt;options&gt;
              &lt;option&gt;
                 &lt;name&gt;addAllRoles&lt;/name&gt;
                 &lt;value&gt;false&lt;/value&gt;
              &lt;/option&gt;
              &lt;option&gt;
                 &lt;name&gt;addRoles&lt;/name&gt;
                 &lt;value&gt;false&lt;/value&gt;
              &lt;/option&gt;
           &lt;/options&gt;

Have you looked xml tools (some xslt), stylesheet, ... they are usually the best for xml manipulation ?

Just post the input and the desired output.