I have a XML document “data.xml”:
I need to write python script which can replace all the value nodes with tag ‘Num’ with the new numbers and write it back to the disk.
the difference is that the new value is not string, but a series of continous increasing number, like 1000,1100,1200,1300…
I hav done research online, most code samples are string replace, not such variable replace. Anybody hav good idea? sample as follow:
before change:
<Param><Num>123</Num></Param>
<Param><Num>123</Num></Param>
<Param><Num>123</Num></Param>
after change:
<Param><Num>1000</Num></Param>
<Param><Num>1100</Num></Param>
<Param><Num>1200</Num></Param>
Quite easy to achieve with the lxml library