我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用lxml.etree.strip_attributes()。
def protect(self): """ Find all elements with a 'Protected=False' attribute and replace the text with a protected value in the XML element tree. If there was a 'ProtectedValue' attribute, it is deleted and the 'Protected' attribute is set to 'True'. The 'ProtectPassword' element in the 'Meta' section is also set to 'True'. This does not just restore the previous protected value, but reencrypts all text values of elements with 'Protected=False'. So you could use this after modifying a password, adding a completely new entry or deleting entry history items. """ self._reset_salsa() self.obj_root.Meta.MemoryProtection.ProtectPassword._setText('True') for elem in self.obj_root.iterfind('.//Value[@Protected="False"]'): etree.strip_attributes(elem, 'ProtectedValue') elem.set('Protected', 'True') protected_text = self._protect(elem.text) elem._setText(protected_text)