[jdom-interest] Fwd: Replacing an element with another element
mark.drew at gmail.com
Mon Feb 26 00:15:58 PST 2007
first time poster so go easy on me :)
I have a document, that I want to replace an Element with another
Element (from a different document). I have tried a number of things
but dont seem to be able to get it right.
(A little more background, I have a document tree, when you select an
Element, you can see the whole Element's text in a text field that
you can edit it. When you are done editing that Element, it creates a
new document with just that Element, I now want to replace the
original element with that text)
Here is what I have so far...
StringBuffer StringBuffer1 = new StringBuffer(editedElementText);
Bis1 = new ByteArrayInputStream(StringBuffer1.toString
LineNumberSAXBuilder builder = new LineNumberSAXBuilder();
Document document = builder.build(Bis1);
Element content = (Element)document.getRootElement().clone();
selNode.setElement(content); //the orignial node
XMLOutputter outputter = new XMLOutputter();
String modDocument = outputter.outputString(selNode.getElement
but it doesnt seem to change the original document.
Many thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest