You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by "Rodriguez, Victor" <vr...@solant.com> on 2001/02/07 22:05:10 UTC

How do I go from a Document to a String?

Greetings,

I have an org.w3c.dom.Document in memory and I need to put it into a String
object.

How can I do this?  Your prompt reply is appreciated!

Regards,
 
--
Victor Rodriguez
Software Engineer - Avolent, Inc. (formerly Solant, Inc.)
Tel: 303-583-3733  Fax: 303-652-6072 
 
Come visit us at http://www.avolent.com <http://www..com> .

Re: How do I go from a Document to a String?

Posted by dane summers <ds...@yahoo.com>.
Heres the way I've done it:
      

boolean pretty = true;
StringWriter result = new StringWriter();
PrintWriter pw = new PrintWriter(result);
XMLSerializer text = new XMLSerializer(pw,new
OutputFormat(doc,"UTF-8",pretty));

try {
  text.serialize(doc);
} catch(IOException ioe) {
  ioe.printStackTrace();
}

return result.toString();

Good luck.
Dane Summers
Synergy Solutions.

--- "Rodriguez, Victor" <vr...@solant.com> wrote:
> Greetings,
> 
> I have an org.w3c.dom.Document in memory and I need
> to put it into a String
> object.
> 
> How can I do this?  Your prompt reply is
> appreciated!
> 
> Regards,
>  
> --
> Victor Rodriguez
> Software Engineer - Avolent, Inc. (formerly Solant,
> Inc.)
> Tel: 303-583-3733  Fax: 303-652-6072 
>  
> Come visit us at http://www.avolent.com
> <http://www..com> .
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-cvs-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-cvs-help@xml.apache.org
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/