Reviewed-By: Ramon Medeiros <ramonn(a)br.ibm.com>
On 01/27/2016 05:20 PM, Lucio Correia wrote:
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/xmlutils/utils.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/wok/xmlutils/utils.py b/src/wok/xmlutils/utils.py
index b75ca51..d02139c 100644
--- a/src/wok/xmlutils/utils.py
+++ b/src/wok/xmlutils/utils.py
@@ -1,7 +1,7 @@
#
# Project Wok
#
-# Copyright IBM, Corp. 2014-2015
+# Copyright IBM, Corp. 2014-2016
#
# Code derived from Project Kimchi
#
@@ -46,6 +46,17 @@ def xml_item_update(xml, xpath, value, attr=None):
return ET.tostring(root, encoding="utf-8")
+def xml_item_remove(xml, xpath):
+ root = ET.fromstring(xml)
+
+ element = root.find(xpath)
+ parent = root.find(xpath + "/..")
+ if parent:
+ parent.remove(element)
+
+ return ET.tostring(root, encoding="utf-8")
+
+
def dictize(xmlstr):
root = objectify.fromstring(xmlstr)
return {root.tag: _dictize(root)}
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn(a)br.ibm.com