How to replace the two last digits from an xml file?

awel albert.wellens at gmail.com
Fri Mar 6 14:53:21 EST 2009


Hi,

I am trying to get a value from an xml file, increment it by 1,
replace by the new value and write another xml with the new value
inside.

I have found this code to get the line and it works but I have to do
everything manualy:

import re
lines = open("c:\\File1.xml").readlines()
for i in range(len(lines)):
    if re.search('national.number', lines[i]):
        lines[i] = lines[i].replace
('01aaa0000000002','01aaa0000000003')
open("File2.xml","w").writelines(lines)

The goal I am trying to reach is to create 30 different xml.

Could someone help me?

Thanks
Al



More information about the Python-list mailing list