From dc74a5264fe60b21e9213c6ed119ed87882d1476 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Tue, 16 Oct 2018 14:42:25 +0100 Subject: [PATCH] [VIVO-1608] Fix node removal from the XML so that it works with an XML tree of arbitrary depth (#89) Resolves: https://jira.duraspace.org/browse/VIVO-1608 --- .../customlistview/CustomListViewConfigFile.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/customlistview/CustomListViewConfigFile.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/customlistview/CustomListViewConfigFile.java index cf8e0ea4c..56aae2bd2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/customlistview/CustomListViewConfigFile.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/customlistview/CustomListViewConfigFile.java @@ -197,7 +197,12 @@ public class CustomListViewConfigFile { */ NodeList doomed = element.getElementsByTagName(tagName); for (int i = doomed.getLength() - 1; i >= 0; i--) { - element.removeChild(doomed.item(i)); + /* + * As the node to be removed may be at an arbitrary depth in the DOM tree, + * we need to get the parent of the node that we are trying to remove, + * and then remove the child from there. + */ + doomed.item(i).getParentNode().removeChild(doomed.item(i)); } }