Hi Tony,
 
there are 2 main scenario's for working with DOM/DOM4J together:
 
1. using DOMReader/DOMWriter:
========================
this convert a DOM tree to a DOM4J tree and visa versa:
 
// convert DOM4J -> DOM
DOMWriter writer = new DOMWriter();
org.dom4j.Document dom4jDoc = [...];
org.w3c.dom.Document w3cDoc = writer.writer(dom4jDoc);
 
// convert DOM -> DOM4J
DOMReader reader = new DOMReader();
org.w3c.dom.Document w3cDoc = [...];
org.dom4j.Document dom4jDoc = reader.read(w3cDoc);
 
However, this approach will do an entire tree walk of the dom/dom4j source tree to create the result. In addition, you will end up with 2 seperate trees: one for DOM and one for DOM4J.
 
 
2. Using DOMDocumentFactory
=======================
this will create one tree for both the DOM and DOM4J objects.
 
This approach can be used if you don't have a DOM or DOM4J document yet, for instance if you still have to parse your XML file using SAX.
 
DOMDocumentFactory factory = new DOMDocumentFactory();
SAXReader reader = new SAXReader(factory);
InputStream in = [...] // your XML file for instance
org.dom4j.Document dom4jDoc = reader.read(in);
org.w3c.dom.Document w3cDoc = (org.w3c.dom.Document) dom4jDoc;
 
 
regards,
Maarten

tony k <[EMAIL PROTECTED]> wrote:
i get the impression that this type of conversion back and forth from
w3c Element to dom4j Element can be accomplished via DOMReader/Writer,
but it isn't apparent to me how.

can some kind soul provide some sample code?

if this is even possible, anyone know how "costly" these operations
might be?
i.e.: is there some slick casting going on under the hood or does it involve
an entire tree walk of the source and memory allocation/construction of
the target?

thanks a bunch!




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Reply via email to