java - Casting JDom 1.1.3 Element to Document without DocumentBuilderFactory or DocumentBuilder -
i need find easier , efficient way convert jdom element (with it's tailoring nodes) document
. ownerdocument( )
won't work version jdom 1
.
moreover, org.jdom.illegaladdexception: content has existing parent "root"
exception occurs when using following code.
documentbuilderfactory dbfac = documentbuilderfactory.newinstance(); documentbuilder dbuilder = dbfac.newdocumentbuilder(); document doc = null; element elementinfo = getelementfromdb(); doc = new document(elementinfo); xmloutputter xmloutput = new xmloutputter(); byte[] byteinfo= xmloutput.outputstring(elementinfo).getbytes("utf-8"); string stringinfo = new string(byteinfo); doc = dbuilder.parse(stringinfo);
i think have use following method of element.
document doc = <element>.getdocument();
refer api documentation says
return parent's owning document or null if branch containing parent not attached document.
Comments
Post a Comment