Reputation: 335
I want to create the xml file from the string i.e I have one String Which I want to convert into xml file,How to do it ?
Upvotes: 1
Views: 138
Reputation: 13151
Try the following code:
String pathname="D:\\XML files\\text.xml"; //specify your file path here
FileWriter out=new FileWriter(pathname);
out.write(str); // Assuming that str contains text to be writen in xml file i.e. well formed xml string
out.close();
If above does not work, Write :
out.write(str.trim());
instead.
Upvotes: 1