user1196969
user1196969

Reputation: 335

To make the xml file from string

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

Answers (1)

Priyank Doshi
Priyank Doshi

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

Related Questions