import os
import sys
from lxml import etree
tree = etree.parse("pom.xml")
for elem in tree.findall("{http://maven.apache.org/POM/4.0.0}version"):
assert elem.text == sys.argv[1]
elem.text = sys.argv[2]
with open("pom.xml", 'w') as file_handle:
file_handle.write(etree.tostring(tree, pretty_print=True, encoding='utf8'))
The above Python script can edit the version of pom file which is located in present directory.
But I want to edit all the pom files which are available in all directories through python script .Please find me a solution thankyou.
to find all files Linux command: $find . -name "pom.xml"