I have an xml file that I made some changes on and now I would like to export it.
I wrote this code like this:
import xml.etree.ElementTree as ET
import numpy as np
import pandas as pd
# parsing directly.
tree = ET.parse(r'''C:\Users\barbsmor\ArticleData_0200_20210707.xml''')
print('file loaded')
root = tree.getroot()
print(root)
print('root printed')
df = pd.read_excel(r'''C:\Users\data_new_all.xlsx''', engine='openpyxl')
for i in range(1):
    for child in root:
        for child1 in child:  
            for child2 in child1:
                
                if child2.tag == 'LineNumber':
                    print(child2.text)
                    line_number_value = child2.text
                        
                    price_new = df.loc[df['line'] == line_number_value, 'new_price']
                    per_new = df.loc[df['line'] == line_number_value, 'new_per']
                for child3 in child2:
                    if child3.tag == 'GrossPrice':
                        child3.text = price_new
                        
                    for child4 in child3:
                        if child4.tag == 'NumberOfUnitsInPriceBasis':
                            child4.text = per_new                            
print('changes done')
tree.write(r'''C:\Users\test.xml''')
The xml is very nested so I hope all of that works.
But it seems I can't export the data with. How can I export the changed data?
tree.write(r'''C:\Users\test.xml''')
I get this error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
 
    