[jdom-interest] Fwd: Replacing an element with another element
Mark Drew
mark.drew at gmail.com
Mon Feb 26 00:15:58 PST 2007
Hi there
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)
Any ideas?
Here is what I have so far...
StringBuffer StringBuffer1 = new StringBuffer(editedElementText);
ByteArrayInputStream Bis1;
try {
Bis1 = new ByteArrayInputStream(StringBuffer1.toString
().getBytes("UTF-8"));
LineNumberSAXBuilder builder = new LineNumberSAXBuilder();
builder.setValidation(false);
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
().getDocument());
System.out.println(modDocument);
}
....
but it doesnt seem to change the original document.
Many thanks in advance
Mark Drew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20070226/82bf84ab/attachment.htm
More information about the jdom-interest
mailing list