Yes that will work too.
just change the:

/** Print writer. */
  protected PrintWriter out;

to an appropriate String writer.

Remember to include the xercesSamples.jar in your classpath. You may also want to turn on canonical output.


Thanks,

       Jeffrey Rodriguez
       XML development
       IBM Cupertino



From: "Linda Derezinski" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
Subject: RE: Document toString()?
Date: Fri, 24 Mar 2000 14:14:18 -0500

If that doesn't work for you, modify the DomWriter sample code to what you
need.


Linda Derezinski Interface & Control Systems

 -----Original Message-----
From:   Jeffrey Rodriguez [mailto:[EMAIL PROTECTED]
Sent:   Friday, March 24, 2000 1:49 PM
To:     [EMAIL PROTECTED]
Subject:        Re: Document toString()?

Mr. Gaitonde,
You could try using the org.apache.xml.serializer classes.

Something like this may do what you want:

import org.apache.xml.serialize.*;
import java.io.*;


. . OutputFormat format = new OutputFormat( doc ); StringWriter stringOut = new StringWriter(); XMLSerializer serial = new XMLSerializer( stringOut, format ); serial.serialize( doc.getDocumentElement() );


Then you can access the string:

   System.out.println( "STRXML = " + stringOut.toString() );




Thanks, Jeffrey Rodriguez XML Development IBM Cupertino





>From: Salil Gaitonde <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Document toString()?
>Date: Fri, 24 Mar 2000 08:53:42 -0800 (PST)
>
>Hi,
>
>I am new to the Xerces-J parser... I'd previously
>been using Sun's parser.
>
>I am trying to get a Document "toStringed" so that
>I can send it to a back-end legacy app which currently
>doesn't understand DOM.
>
>Sun's parser handled this easily because I could just do
>a Document.toString() and the entire tree would flatten
>into a string...  "<hello>there</hello>"
>
>Is there an easy way to do this sort of thing with Xerces?
>Thanks,
>Salil
>
>__________________________________________________
>Do You Yahoo!?
>Talk to your friends online with Yahoo! Messenger.
>http://im.yahoo.com

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com



______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com



Reply via email to