How to remove a child from from a node using jdom in java?

三世轮回 提交于 2019-12-02 04:50:47

You'll need to do this:

List<Element> elements = new ArrayList<Element>();

while (subchilditr.hasNext()) {
    Element subchild = (Element) subchilditr.next();
    if (subchild.getText().equalsIgnoreCase(text)) {
        elements.add(subchild);
    }
}

for (Element element : elements) {
    element.getParent().removeContent(element);
}

If you try to remove an element inside of the loop you'll get a ConcurrentModificationException.

If you have the parent element rurl you can remove its children using the method removeChild or removeChildren.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!