On 08/01/2012 09:09 PM, Yu Mingfei wrote:
@@ -140,6 +140,16 @@ class XMLBase(ElementTree.ElementTree, XMLBackup):
except (OSError, IOError):
return False

+ def remove(self, element):
+ """
+ Removes a matching subelement.
+
+ @param element is What to be removed.
+ @return a new element tree.
+ """
+ assert self._root is not None
+ return self._root.remove(element)
+

Best to not use private properties here. Something like this is cleaner:

root = self.get_root()
assert root is not None
return root.remove(element)

This actually turned out to be a LOT trickier. The remove() method only works on _SUBELEMENTS_, however there is no convenient way to access the parent of a given element. Luckily, I found a elegant solution on google...

--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to