Have you tried to use <Element>.detach() like in the code I sent? --Evan
Devang Joshi wrote: > I am trying to delete first device element from my xml document. > iterateToDevicePosition() function returns me the first device element, > But doc.remove() did not work for me. (Note: doc has the parsed xml > file) > > //Now delete the first device element > Element dummyElem = iterateToDevicePosition(); > //Now dummy element has the element I want to remove > doc.remove(dummyElem); //This does not remove it from the doc??? > > Thanks, > Devang > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Evan S. > Kirkconnell > Sent: Tuesday, March 13, 2007 7:52 AM > To: dom4j-user@lists.sourceforge.net > Subject: Re: [dom4j-user] convert String to Element > > (Element)DocumentHelper.parseText(xml).getRootElement().detach() > > As a forewarning, I think this creates the element in the null > namespace. If you need it in the xhtml namespace, you may have to do a > little more work. > --Evan > > ----- Original Message ----- > From: Devang Joshi <[EMAIL PROTECTED]> > Date: Monday, March 12, 2007 4:44 pm > Subject: [dom4j-user] convert String to Element > To: dom4j-user@lists.sourceforge.net > > >> I am trying to create clone of element then convert the element to >> string. Do some string manipulation and then convert the string >> back to >> element. >> >> //***This will insert new elements inside the clone*** >> Element newElement = (Element) currElement.clone(); >> >> //***We need to replace few values in the new element so convert to >> string*** >> String strElem = newElement.asXML(); >> >> // Do something with string (internal logic) >> >> How do I convert string to element and insert that in my xml >> document????????????????????????? >> >> //this would put the element in the doc >> this.insertElementAt(newElement, this.root.indexOf(currElement)+1); >> >> >> >> Thanks, >> >> Devang >> >> 972-550-2746 >> >> >> >> >> > > ------------------------------------------------------------------------ > - > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE > V > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user