Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove attribute of a etree Element?

I've Element of etree having some attributes - how can we delete the attribute of perticular etree Element.

like image 262
shahjapan Avatar asked Apr 27 '10 10:04

shahjapan


People also ask

How do I change the root element in XML in Python?

_setroot(element): For replacing the root of a tree we can use this _setroot object. So it will replace the current tree with the new element that we have given, and discard the existing content of that tree. getroot(): The getroot() will return the root element of the tree.

What is XML etree ElementTree?

The xml.etree.ElementTree module implements a simple and efficient API for parsing and creating XML data. Changed in version 3.3: This module will use a fast implementation whenever available.

What is an Etree?

An E-Tree is a rooted multipoint service that connects a number of UNIs providing sites with hub and spoke multipoint connectivity. Each UNI is designated as either root or leaf. A root UNI can communicate with any leaf UNI, while a leaf UNI can communicate only with a root UNI.

How do you process XML in Python?

To read an XML file using ElementTree, firstly, we import the ElementTree class found inside xml library, under the name ET (common convension). Then passed the filename of the xml file to the ElementTree. parse() method, to enable parsing of our xml file. Then got the root (parent tag) of our xml file using getroot().


1 Answers

The .attrib member of the element object contains the dict of attributes - you can use .pop("key") or del like you would on any other dict to remove a key-val pair.

like image 189
Amber Avatar answered Sep 22 '22 22:09

Amber