[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
This commit is contained in:
Graham Triggs 2018-10-16 14:42:25 +01:00 committed by Andrew Woods
parent 5ca7a9235f
commit dc74a5264f

View file

@ -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));
}
}