Apr-06-2021, 01:08 PM
I have the following Python code:
I shall be grateful if someone can help?
def xml_parsing(file_name, tag_name, source_string_list, target_string_list): from xml.etree import ElementTree with open(file_name, 'rb+') as f: tree = ElementTree.parse(f) root = tree.getroot() element = root.find(tag_name) ElementTree.dump(element)The output of this (variable tag_name is outputParameters) is;
Output:</outputParameters>
element[0] = <Element 'folder' at 0x13de8da0>
Attribute None
<outputParameters>
<folder automatic="1" destination="C:\Users\ataneja\ajay\miscellaneous\" extension="*" folderPath="C:\Users\ataneja\ajay\miscellaneous\" id="targetDir" type="bin" upLoadable="RightNow" />
<ReportName>GlobalResults</ReportName>
</outputParameters>
In the above I want to edit the value of "destination". I thought that might be an attribute but it is not, because when I give the following line in the Python codeprint('element.attrib = ', element.attrib)I get;
Output:element.attrib = {}
Attribute None
How do I go about editing the value of destination, it is neither a text not an attribute.I shall be grateful if someone can help?