Example usage for org.dom4j.tree DefaultElement elementByID

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

Introduction

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

Prototype

public Element elementByID(String elementID) 

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 {//from  w  w  w  .  j ava  2s .com
            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;
}