Modify XML node using Python
<p>I am taking an XML file as an input, have to search with a keyword i.e <code>GENTEST05</code>.
If found , then I need to pick up its parent node (in this example I want to pick up <code>&lt;ScriptElement&gt;</code>) and then replace the complete node <code>&lt;ScriptElement&gt;blahblah&lt;/ScriptElement&gt;</code> with a new content.</p>

<pre><code>...
...
&lt;ScriptElement&gt;
&lt;ScriptElement&gt;
&lt;ScriptElement&gt;
    &lt;ElementData xsi:type="anyData"&gt;
        &lt;DeltaTime&gt;
        &lt;Area&gt;
        &lt;Datatype&gt;USER PROMPT [GENTEST05]&lt;/Datatype&gt;
        &lt;Description /&gt;
        &lt;Multipartmessage&gt;False&lt;Multipartmessage&gt;
        &lt;Comment&gt;false&lt;/Comment&gt;
    &lt;/ElementData&gt;
&lt;/ScriptElement&gt;
&lt;ScriptElement&gt;
&lt;ScriptElement&gt;
...
...
...
</code></pre>

<p>I am trying to do this using Beautifulsoup. This is what I've done so far but not getting a proper way to proceed. Other than beautifulsoup, ElementTree or any other suggestion is welcome.</p>

<pre><code>import sys
from BeautifulSoup import BeautifulStoneSoup as bs
xmlsoup = bs(open('file_xml' , 'r'))

a = raw_input('Enter Text')
paraText = xmlsoup.findAll(text=a)
print paraText
print paraText.findParent()
</code></pre>