ya, i do almost exactly the same thing. the problem is that the DOM i'm writing out has been parsed by xerces from an XML document that had no newlines, only tabs between tags...and i was really praying that xerces would figure out that i like every tag on its own line, indented nicely. ;)
eric.
On Thu, May 17, 2001 at 09:48:22AM +1000, Anthony Ikeda wrote:
> My code outputs fine:
>
> public static String serializeDoc(Element doc){
> String xmlString = new String();
> StringWriter stringOut = new StringWriter();
> OutputFormat opfrmt = new OutputFormat(doc.getOwnerDocument(), "UTF-8",
> true);
> opfrmt.setIndenting(true);
> opfrmt.setPreserveSpace(false);
>
> XMLSerializer serial = new XMLSerializer(stringOut, opfrmt);
>
> try{
> serial.asDOMSerializer();
> serial.serialize( doc );
> xmlString = stringOut.toString();
> } catch(java.io.IOException ioe){
> xmlString=null;
> }
> return xmlString;
> }
>
> Let me know if you still have problems
> ----- Original Message -----
> From: "Eric" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 16, 2001 2:30 PM
> Subject: problems formatting output
>
>
> > I've been having some troubling problems using OutputFormat to write
> > out a DOM. I'm basically parsing some ugly XML (spaces before '>'s,
> > no newlines, etc.) into a DOM and then writing it back
> > out. I've traversed the DOM and it looks like it gets parsed just
> > fine, but when I use OutputFormat to write it out, the output still
> > has ugliness (although different from the input). Tags are
> > word-wrapped so that they split over lines, etc. It looks like this:
> >
> > <time>15:04:27</time> <anten
> > type="broadcast"> <Station num="17650">
> >
> > What am I doing wrong???
> >
> > Thanks,
> > Eric.
> >
> > --
> > _____ _
> > | ____|(_) http://ir.iit.edu/~ej
> > | _| | | Page me via ICQ at
> > | |___ | | http://wwp.mirabilis.com/19022931
> > |______/ | or by mailing [EMAIL PROTECTED]
> > |__/
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
_____ _
| ____|(_) http://ir.iit.edu/~ej
| _| | | Page me via ICQ at
| |___ | | http://wwp.mirabilis.com/19022931
|______/ | or by mailing [EMAIL PROTECTED]
|__/
pgpv87mbR3e1X.pgp
Description: PGP signature
