title: Modifying POM.xml using python , lxml and xpath
body: <p>Hi all lets assume a sample POM.xml file ,</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&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/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;groupId&gt;com.xyz.app&lt;/groupId&gt;
  &lt;artifactId&gt;com.xyz.app&lt;/artifactId&gt;
  &lt;version&gt;1.0.55-SNAPSHOT&lt;/version&gt;
  &lt;dependencies&gt;
      &lt;!-- Compile Dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.xyz.app&lt;/groupId&gt;
          &lt;artifactId&gt;com.xyz.app.random1&lt;/artifactId&gt;
          &lt;version&gt;1.0.2-SNAPSHOT&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.xyz.app&lt;/groupId&gt;
          &lt;artifactId&gt;com.xyz.app.random2&lt;/artifactId&gt;
          &lt;version&gt;1.0.7-SNAPSHOT&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.xyz.app&lt;/groupId&gt;
          &lt;artifactId&gt;com.xyz.random3&lt;/artifactId&gt;
          &lt;version&gt;1.0.2-SNAPSHOT&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.xyz.app&lt;/groupId&gt;
          &lt;artifactId&gt;com.xyz.app.random4&lt;/artifactId&gt;
          &lt;version&gt;1.0.7-SNAPSHOT&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>Now i  want to update the version of the dependencies to the latest one . I have the latest depndencies in a dictionary where the key is the dependencies and the values is the latest version . </p>
  
  <p>Now i am trying to access each dependency element using the following code </p>
  
  <pre><code>root = etree.parse("C:\Temp\python workspace\pom.xml")
  root = etree.tostring(root)
  root = etree.XML(root)
  for parent in root.xpath('//dependency'):
    children = parent.getchildren()
    for child in children:
        print child.text
  </code></pre>
  
  <p>But i'am not getting any output , could some one point out what i'am doing wrong here ?</p>