You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by jn...@Ementor.dk on 2001/07/04 15:54:11 UTC
saving and printing the DOMDocument?
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
Re: saving and printing the DOMDocument?
Posted by Willy Ching <wi...@itistech.com>.
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
Re: saving and printing the DOMDocument?
Posted by Rajan Gupta <ra...@rocketmail.com>.
Check out the DOMPrint sample in Xerces for C++ & port that to Java.
--- 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
>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org