![]() ![]() Print "for-loop check : loop has been entered"Ĭurrent_xml_tree.getroot().remove(weight_value_elem) Print weight_value_elem # Location of element 'weight' is listedįor weight_node_loc in current_xml_er('weight'): Print weight_nodes # result is an empty list Weight_nodes = current_xml_root.findall('weight') ![]() # Get all nodes entitled 'weight' from element Weight_value = weight_value_elem.get('value') Thus far, I have the following code: from xml.etree import ElementTreeĬurrent_xml_tree = ElementTree.parse(filename_path) # Path to example.xmlĬurrent_xml_root = current_xml_tree.getroot()Ĭurrent_xml_level_2_node = current_xml_root.findall('XML_level_2')įor weight_value_elem in current_xml_er('weight'): Using the xml code (let's just say it is called "example.xml"): Goal: remove the sub-element "weight" from the XML file. However, there is a push to use Python in my group so I am using this as both a functional and learning exercise.Ĭould you please correct my use of terms and understanding? I do not simply just want the code to work, but to know that my understanding of how it works is correct. I hope to save myself a great deal of manual effort by making these changes automated and typically I would have just done this in a language such as C++ that I am more familiar with. Selecting a region changes the language and/or content on need help adjusting my XML file with Python and the elementTree library.įor some background, I am not a student and work in industry.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |