You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Raju Vaidya <va...@fokus.gmd.de> on 2001/10/02 11:42:49 UTC

dom to String

Hi all,

I am new in using xalan.

I am using xalan-j for a corba project. i am sending 'xml' from client to
server and vice versa as String. therefore is it possible to convert dom
object to String using 'serializer' or something else. and is it possible to
converted this 'String' representing xml doc to dom?

i can save use SerializerFactory to dom object and save it to a file using
serializer.setOutputStream(new FileOutputStream("filename.xml"));
i can read the file and save it it string. it would be better if i can copy
to String directly.

I would be greatful if someone can help.

regards,
R.N. Vaidya


Re: dom to String

Posted by Harald Hett <h....@gis-systemhaus.de>.
Hi, Raju!

Instead of using a FileOutputStream you could use a
ByteArrayOutputStream:
	
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	serializer.setOutputStream(out);
	...		
	out.flush();
	out.close();
	System.out.println("xml string is " + out.toString());
	
Bye, 
Harald
-- 
Harald Hett <h....@gis-systemhaus.de>
Gesellschaft für integrierte Systemplanung



Raju Vaidya wrote:
> 
> Hi all,
> 
> I am new in using xalan.
> 
> I am using xalan-j for a corba project. i am sending 'xml' from client to
> server and vice versa as String. therefore is it possible to convert dom
> object to String using 'serializer' or something else. and is it possible to
> converted this 'String' representing xml doc to dom?
> 
> i can save use SerializerFactory to dom object and save it to a file using
> serializer.setOutputStream(new FileOutputStream("filename.xml"));
> i can read the file and save it it string. it would be better if i can copy
> to String directly.
> 
> I would be greatful if someone can help.
> 
> regards,
> R.N. Vaidya