[jdom-interest] Convert an org.w3c.dom.Document to java.io.InputStream

Brett McLaughlin brett.mclaughlin at lutris.com
Tue Oct 3 11:26:34 PDT 2000


David Parker wrote:
> 
> Hello,
> 
> I'm getting a "org.w3c.dom.Document" from a database and I need to
> convert it to  "java.io.InputStream"
> so that I can create a "org.jdom.Document" with the method
> build(java.io.InputStream in).


No you don't ;-)

DOMBuilder builder = new DOMBuilder();
org.jdom.Document doc = builder.build(domDoc);

Conversion is stright from DOM to JDOM.

-Brett

> 
> Is it possible to cast one Document to another?
> -------------------------------------------------------------------------------------------------------------------------------------------------------
> // returns a  org.w3c.dom.Document
> domDoc = student.getClassesDOM(conn, "UGRD");
> 
> if (doc != null)
> {
> 
>         try {
>         // Request document building without validation
>                 org.jdom.input.SAXBuilder builder = new
> org.jdom.input.SAXBuilder(false);
> 
>                 org.jdom.Document jDoc = builder.build(xmlSource);
>      //This builds a document from the supplied input stream.
> 
>                 // Get the root element
>                 org.jdom.Element root = jDoc.getRootElement();
>                 List allChildren = root.getChildren(); //return all
> children
> 
>             } catch (Exception ejdom) {
>                       ejdom.printStackTrace();
>             }
> 
> 
> 
> 
> Sincerely,
> David Parker
> 
> mailto:david.parker at doit.wisc.edu
> 
> Library, Instructional & Retrieval Applications,
> DoIT - University of Wisconsin-Madison
> 1210 West Dayton Street, Madison WI  53706
> Phone: 608.265.7829     FAX: 608.265-6453

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list