
Reviewed by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> On 27-01-2016 17:20, Lucio Correia wrote:
Signed-off-by: Lucio Correia <luciojhc@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)}
-- Jose Ricardo Ziviani ----------------------------- Software Engineer Linux Technology Center - IBM