Skip to content
Advertisement

Edit XML file with python

I have an XML file autogenerated with Informatica BDM, it´s very complex for me to edit values I made several attempts with xml.etree.ElementTree but I do not get results. This is an extract from the file:

JavaScript

My idea would be to be able to change the parameters, for example: <parameter name="P_s_spark_executor_memory">8G</parameter> to <parameter name="P_s_spark_executor_memory">16G</parameter>

I can only access the values, but not their content and I can’t edit them either:

JavaScript

The idea would be to be able to overwrite any parameter:

JavaScript

and that it is changed in the file by <parameter name="P_s_spark_sql_shuffle_partitions">64</parameter>

Advertisement

Answer

Try this code:

JavaScript

Output c:testtestOut.xml

JavaScript
Advertisement