Hi, it seems it has nothing to do width dom4j. In dom4j you can remove element from its parent, for example:
element.getParent().remove(element); Filip Jirsák 2009/8/3 Laurent Morissette <laurent.morisse...@gmail.com>: > Hi All ! > I come to you today in hope that someone could find a solution to a show > stopper issue that I have regarding removal of element > > Here is the code that is supposed to remove: > > <pre> > //Snippet from BlogCategoryRepository > /** > * Removes a Category in a blog > * @param t > * @return > * @throws com.mor.blogengine.exception.NoMatchesFoundException > */ > public boolean remove(BlogCategory t) throws NoMatchesFoundException { > > > IXmlFileManager<Element> xmlFileManagerImpl = null; > > try { > xmlFileManagerImpl = > XmlFileManagerImpl.getInstanceForDoc(XML_FILE,validate); > } catch (Exception ex) { > Logger.getLogger(BlogEntryRepository.class.getName()) > .log(Level.SEVERE, null, ex); > } > > //the following uses XPATH 2.0 psychopath processor > DefaultElement de = (DefaultElement) > getElementsForCriteria(SearchCriteria.SINGLE, > Integer.toString(t.getHashCode())).get(0); > boolean isPresent=(de!=null); > List<Element> lFoundList=new ArrayList<Element>(); > System.out.println("Is element present in XML? "+ isPresent); > if (de == null) { > throw new NoMatchesFoundException(); > } > > lFoundList.add(de); > > > xmlFileManagerImpl.remove(lFoundList); > xmlFileManagerImpl.saveChanges(); > > return true; > } > </pre> > > This is the remove method I use in XmlFileManager: > > <pre> > public boolean remove(List<Element> removeBatch) { > System.out.println("in remove method of XmlFileManager.... "); > boolean removed = false; > for (Element defaultElement : removeBatch) { > removed= mRootElement.remove(defaultElement); > > > > } > saveChanges(); > return removed; > } > </pre> > > here is the log produced when running a remove test: > > <pre> > getting an instance of XmlFileManager.... > init of XmlFileManager.... > 2009-08-02 19:21:53 com.mor.blogengine.xpath.SearchEngine getSingleElement > INFO: Building XPath search Query > XPATH2.0 Query is /Blog//catego...@hash=xs:double(56480685)] > Is element present in XML? true > in remove method of XmlFileManager.... > Saving... > > </pre> > > > > Whatever I do.. It does'nt seem to remove the element > > > Well that's my issue.. I hope I was clear enough to make it understable.... > if not I can elaborate more :) > > Any ideas whats wrong ? > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user