Example usage for org.dom4j.tree DefaultElement remove

List of usage examples for org.dom4j.tree DefaultElement remove

Introduction

In this page you can find the example usage for org.dom4j.tree DefaultElement remove.

Prototype

public boolean remove(Attribute attribute) 

Source Link

Usage

From source file:com.mor.blogengine.xml.XMLHandlerImpl.java

License:Open Source License

@Override
public boolean remove(DefaultElement child, String parentID) {
    boolean removed = false;
    DefaultElement foundParent = (DefaultElement) mRootElement.elementByID(parentID);

    if (foundParent != null) {
        try {//ww  w . jav  a2 s  .  c o  m
            trace("Parent found{0}");
        } catch (MissingPropertyException | IncorrectPropertyValueException ex) {
            Logger.getLogger(XMLHandlerImpl.class.getName()).log(Level.SEVERE, null, ex);
        }

        DefaultElement foundChild = (DefaultElement) foundParent.elementByID(child.valueOf("@ID"));

        if (foundChild != null) {
            try {
                trace("child  found");
            } catch (MissingPropertyException | IncorrectPropertyValueException ex) {
                Logger.getLogger(XMLHandlerImpl.class.getName()).log(Level.SEVERE, null, ex);
            }
            removed = foundParent.remove(foundChild);

            return removed;
        }
    }

    return false;
}