title: Python POM parser replace text
body: <p>xml
  <a href="https://i.stack.imgur.com/8MNGp.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I need change version marked on screen.</p>
  
  <p>I try:</p>
  
  <pre><code>with open(PathPom,'r') as f:
  
      tree = ET.parse(f)
      root = tree.getroot()
  
      for elem in root.getiterator():
          try:
          elem.text = elem.text.replace('1.4.1', '5.0.0')
          except AttributeError:
          pass
  
  tree.write(PathPom,xml_declaration=True, method='xml')
  </code></pre>
  
  <p>All versions 1.4.1 in pom are replace, and all line in document starts with <code>&lt;ns0</code></p>
  
  <p><strong>Do you have any idea how to solve it?</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 [http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;cterminal&lt;/groupId&gt;
      &lt;artifactId&gt;Monitor&lt;/artifactId&gt;
      &lt;version&gt;1.4.1&lt;/version&gt;
      &lt;packaging&gt;lba&lt;/packaging&gt;
      &lt;properties&gt;
          &lt;lb.middlewareVersion&gt;1.7.0&lt;/lb.middlewareVersion&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;.maven&lt;/groupId&gt;
                  &lt;artifactId&gt;lba-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${lb.middlewareVersion}&lt;/version&gt;
                  &lt;extensions&gt;true&lt;/extensions&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.4.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;enforce-maven&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;enforce&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;rules&gt;
                                  &lt;requireMavenVersion&gt;
                                      &lt;message&gt;The lba-maven-plugin requires Maven version to be at
                                          least 3.1.1!&lt;/message&gt;
                                      &lt;version&gt;[3.1.1,)&lt;/version&gt;
                                  &lt;/requireMavenVersion&gt;
                                  &lt;dependencyConvergence/&gt;
                              &lt;/rules&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>