i have xml (template) file and i set variables in the xml using {$var}
and i have a list with values for the xml variables.
how can i open (set) my file and set the xml variable to the values from my list ?
<sut>
<Cdu>
<class>XXX</class>
<conn>
<class>XXX</class>
<cli>
<password>{$password}</password>
<user>{$user}</user>
<host>{$host}</host>
<connectOnInit>false</connectOnInit>
</cli>
</conn>
<basic>
<class>XXX</class>
</basic>
</Cdu>
Why not just use f string?
password = 'secret'
user = 'jack'
host = '12.56.78.123'
xml = f'''<sut>
<Cdu>
<class>XXX</class>
<conn>
<class>XXX</class>
<cli>
<password>{password}</password>
<user>{user}</user>
<host>{host}</host>
<connectOnInit>false</connectOnInit>
</cli>
</conn>
<basic>
<class>XXX</class>
</basic>
</Cdu>'''
print(xml)
output
<sut>
<Cdu>
<class>XXX</class>
<conn>
<class>XXX</class>
<cli>
<password>secret</password>
<user>jack</user>
<host>12.56.78.123</host>
<connectOnInit>false</connectOnInit>
</cli>
</conn>
<basic>
<class>XXX</class>
</basic>
</Cdu>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With