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

Jason Hunter jhunter at collab.net
Wed Oct 4 00:31:38 PDT 2000


You don't need the InputStream.  Use org.jdom.input.DOMBuilder (builds
JDOM docs from DOM).

-jh-

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).
> 
> 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



More information about the jdom-interest mailing list