Example usage for org.jdom2 Element removeChild

List of usage examples for org.jdom2 Element removeChild

Introduction

In this page you can find the example usage for org.jdom2 Element removeChild.

Prototype

public boolean removeChild(final String cname) 

Source Link

Document

This removes the first child element (one level deep) with the given local name and belonging to no namespace.

Usage

From source file:rezeptsuperpos.RecipeGUI.java

License:Open Source License

private void delIngredientButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delIngredientButtonActionPerformed
    int currentIngredient = this.recipeIngredientsTable.getSelectedRow();
    Element recipe = recipeArchive.getCurrentElement();
    int ingredIdx = 0;
    Element reducedIngredients = MyElement.createElement("ingredients", "");
    for (Element element : recipe.getChild("ingredients").getChildren()) {
        if (ingredIdx != currentIngredient) {
            Ingredient ingredient = new Ingredient(element);
            reducedIngredients.addContent(ingredient.toElement());
        }//from   w ww .j ava 2  s .co  m
        ingredIdx++;
    }
    ;
    recipe.removeChild("ingredients");
    recipe.addContent(reducedIngredients);
    try {
        recipeArchive.saveRecipes();
    } catch (Exception ex) {
        this.ErrorOptionPane.showMessageDialog(this, ExceptionMessage.couldnotSave);
    }
    set2Recipe(recipeArchive.getCurrentRecipe());
}

From source file:scrum.server.ScrumEntityfilePreparator.java

License:Open Source License

private boolean removeChild(String name, Element root) {
    Element e = root.getChild(name);
    if (e == null)
        return false;
    root.removeChild(name);
    return true;/* www  . j  av a 2 s. c om*/
}