xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willy Ching <wi...@itistech.com>
Subject Re: saving and printing the DOMDocument?
Date Thu, 05 Jul 2001 01:50:33 GMT
Write to a file:
         OutputFormat format  = new OutputFormat(aDoc);
         format.setIndenting(true);
         FileOutputStream fOut = new FileOutputStream(aFilename);
         OutputStreamWriter writer = new OutputStreamWriter(fOut, "UTF-8");
         XMLSerializer    serial = new XMLSerializer( fOut, format );
         serial.asDOMSerializer(); // As a DOM Serializer
         serial.serialize( aDoc.getDocumentElement() );
         fOut.close();

Write to a String:
      StringWriter writer = new StringWriter();
      XMLSerializer serializer = new XMLSerializer(writer,
         new OutputFormat(aDoc));
      serializer.asDOMSerializer();
      serializer.serialize(aDoc.getDocumentElement());
      return writer.getBuffer().toString();


Willy Ching
Software Engineer
ITIS Technologies


jni@Ementor.dk wrote:

> Hi there,
>
> Could some one please tell me how I can
> - save my DOMDocument to file
> - write the entire DOMDocument to a string
>
> In the MSXML parser their exist to methods on the DOMDocument to take care
> of this:
> . save() and .xml()
>
> What is the familiar methods in the Xerces parser?
>
> I hope some one can help me with this problem.
>
> Regards,
> Jess
>
> ---
> Jess Nielsen
> Management Consultant / System Developer
>
> Ementor Denmark A/S
> E-mail: jni@ementor.dk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Mime
View raw message