• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Xml result is not coming.

 
Punya Pratap Singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry if I am posting it wrong forum,as I could not find the appropriate place.
As I am running this code It is working fine but the out put in xml file is not appropriate.

Out put should be ---
like this
---------------------------
But out put is coming as- javax.xml.transform.stream.StreamResult@9444d1

please help me as I am new in XML.

 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of putting a toString() on the StreamResult, you need to convert the StringWriter to a StringBuffer and have the toString() method to it.

stwriter.getBuffer().toString();
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better still, get rid of the wasteful process where you generate XML to a String and then write it to a file (with the wrong encoding by the way). Just generate the XML directly to the file.

(This also removes about ten lines of code from your program. But beginners always write too much code...)
 
Punya Pratap Singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Paul Clapham.
Now Its working fine.and also I will try to write some meaningful code now onwards.
Thanks once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic