File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Problem in creating XML using DOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem in creating XML using DOM" Watch "Problem in creating XML using DOM" New topic
Author

Problem in creating XML using DOM

riya das
Greenhorn

Joined: Sep 16, 2011
Posts: 9
Hi All,

I am writing a servlet code which is supposed to retrieve data from a hashmap, then create an XML file and send it to a javascript that has AJAX functions.
I am using DOM to achieve this. My problem is when I convert the DOM file back into the string to be sent to the javascript, it is not getting formatted properly.
e.g. if i have created a DOM file like <customer><fname>abc</fname><lname>xyz</lname></customer>, the corresponding string turns into:
<customer><fname>abcxyz</fname></lname></customer>.
I am sure I am missing out something very basic here, but I am not sure what.
Would be glad if anybody can help !
Here's my code for the same:
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

On line 20, you have:
Change this to:
riya das
Greenhorn

Joined: Sep 16, 2011
Posts: 9
Dont know how I missed such a stupid mistake and was stuck on it for hours ! :-S
Thank you so much James ! You saved my day !
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

No problem riya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in creating XML using DOM
 
Similar Threads
Result is not appropriate
problem in modification of the value in xml file
Xml result is not coming.
Help regarding how to check the element entered is equal or not in xml file
Java code to append data into a existing xml file