[jdom-interest] trivial question

Van Dooren, Damian VanDoorenD at icfg.com
Tue Oct 3 05:29:46 PDT 2000


Paul,

XMLOutputter is really quite easy to use, here is the code I use to convert
a Document to a String.


    private static String convertToString(Document doc, String indent,
boolean newLines) {
        boolean success = true;
        XMLOutputter outputter = new XMLOutputter(indent, newLines);
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            outputter.output(doc, output);
        }
        catch(IOException ex) {
            success = false;
        }

        if(success) {
            return output.toString();
        }
        else {
            return null;
        }
    }



-----
Damian Van Dooren
Information Technology
The Investment Centre
(519) 672-4389 x718
 

> -----Original Message-----
> From: Paul Madsen [mailto:paul.madsen at coventus.com]
> Sent: Tuesday, October 03, 2000 7:46 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] trivial question
> 
> 
> I want to create a string from a Document object. Is there a quick way
> or must I iterate through the chidlren?
> 
> I can't get XMLOutputter to work, I get complaints about mismatch
> between string and stream.
> 
> As a newbie, I would find more examples of JDOM in action 
> invaluable. So
> far, I'm working off of Elliotte Rusty Harold's presentation. 
> Any other
> collections I'm missing?
> 
> Thanks
> 
> --
> Paul Madsen
> 
> Coventus Intuitive Networks
> 340 Terry Fox Drive, Kanata, On, Ca
> K2K 3A2
> e) paul.madsen at coventus.com
> p) (613) 271-0180 x296
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list