XmlSerializer serializer = Xml.newSerializer();
StringWriter sw = new StringWriter();
try {
serializer.setOutput(sw);
serializer.startDocument("UTF-8", null);
serializer.startDocument(“UTF-8”, null);这样写就好了。