Serialized xml to String



I generate a XML like this, it works fine. But want to print it out in Eliscps:



import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

public class PersonConstructor {
String info="";
String path="c://myfile/myperson";

// here is my xml object
Person person = new Person();
person.setFirstName("fname");
person.setLastName("lname");
person.setTel("111-111-1111");
person.setAddress("1000 main st.");

//Serializer my object to file.
Serializer serializer = new Persister();
File file = new File(path);
serializer.write(person, file);

//now I want to print out my xml file.I don't know how to do it.
info=file.toString
system.out.println(info);
}


should i use output stream? Thanks


No comments:

Post a Comment