aspose file tools*
The moose likes XML and Related Technologies and the fly likes can it be possible to write xml doc into  a string variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "can it be possible to write xml doc into  a string variable?" Watch "can it be possible to write xml doc into  a string variable?" New topic
Author

can it be possible to write xml doc into a string variable?

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
Iam using ajax for my application, i have to create XMLHttpResponse which is an xml

tell me how can i send xml response using stax?

Abhishek
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Hello Abishek,

Do you want to create an xml response on the server side for a request made through and XMLHttpRequest? Then I hope this helps..

Check here for a tutorial on StAX. By clicking the link "Next Page" you can navigate to the next page where you will find instructions on how to create an xml document using the StAX API.
As the article points out, the well formedness of documents that you create through this method is not guaranteed. The user has to take care that the document is well formed.

However it could save you a lot of work creating your xml documents this way.

You could use this in few different ways..

You could pass an OutputStreamWriter to XMLOutputFactory.createXMLStreamWriter(java.io.Writer) and use the returned XMLStreamWriter to write to the writer / stream.

Or use a StringWriter and get the string after the writing is done and use it as you wish.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can it be possible to write xml doc into a string variable?