String filename = "file.txt"; FileOutputStream fos; fos = openFileOutput(filename,Context.MODE_APPEND); XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(fos, "UTF-8"); serializer.startDocument(null, Boolean.valueOf(true)); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "root"); for(int j = 0 ; j < 3 ; j++) { serializer.startTag(null, "record"); serializer.text(data); serializer.endTag(null, "record"); } serializer.endDocument(); serializer.flush(); fos.close();
xmlSerializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
FileOutputStream fos = mContext.openFileOutput("filename", Context.MODE_PRIVATE); BufferedOutputStream buf = new BufferedOutputStream(fos); XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer(); serializer.setOutput(buf, "utf-8"); serializer.startDocument("utf-8", Boolean.TRUE); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "yourRootTag");
xSe.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "root"); } else { serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
FileOutputStream fos=new FileOutputStream(pathof_your_xmlfile); XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(fos, "UTF-8"); serializer.startDocument(null, Boolean.valueOf(true)); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "root");//here add loop for add more names and passwords serializer.startTag(null, "Person"); serializer.attribute(null, "Name", valueof_name); serializer.attribute(null, "Password", valueof_password); serializer.endTag(null, "Person"); serializer.endTag(null, "root"); serializer.endDocument(); serializer.flush(); fos.close();
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "root"); } else { serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
String filename = "file.txt"; FileOutputStream fos; fos = openFileOutput(filename,Context.MODE_APPEND); XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(fos, "UTF-8"); serializer.startDocument(null, Boolean.valueOf(true)); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "root"); for(int j = 0 ; j < 3 ; j++) { serializer.startTag(null, "record"); serializer.text(data); serializer.endTag(null, "record"); } serializer.endDocument(); serializer.flush(); fos.close();
xmlSerializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
public String writeXML(Context ctx) throws IOException{ FileOutputStream fout = null; try { fout = ctx.openFileOutput("answers.xml", Context.MODE_PRIVATE); } catch (FileNotFoundException e) { return e.getMessage(); } XmlSerializer serializer = Xml.newSerializer(); try { serializer.setOutput(fout, "UTF-8"); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "questions"); serializer.startTag(null, "question"); serializer.attribute(null,"grupo" , "test"); serializer.attribute(null,"grupo" , "test"); serializer.text("A"); serializer.endTag(null, "question"); serializer.endTag(null, "questions"); serializer.endDocument(); serializer.flush(); fout.close(); return "write done"; } catch (Exception e) { return e.getMessage(); } }
private static StringWriter createXml(ArrayList<Machine> SelectedMachines) { StringWriter writer = new StringWriter(); XmlSerializer serializer = Xml.newSerializer(); try { serializer.setOutput(writer); serializer.startDocument("UTF-8", true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "Machine"); for (Machine machine : SelectedMachines) { serializer.startTag(null, "Name"); serializer.text(machine.getName()); serializer.endTag(null, "Name"); serializer.startTag(null, "Number"); serializer.text(machine.getNumber()); serializer.endTag(null, "Number"); } if (serializer == null) return null; serializer.endTag(null, "Machine"); serializer.endDocument(); serializer.flush(); writer.close(); } catch (Exception e) { Log.e("createXml", e.toString()); } return writer; }
serializer.startDocument(null, Boolean.valueOf(true)); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output",true); serializer.startTag("", "Document"); for(int i = 0 ; i < myList.size(); i++) {
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
xmlSerializer.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true);
xmlSerializer.setOutput(fileOutputStream, "UTF-8"); xmlSerializer.startDocument(null, null); xmlSerializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); xmlSerializer.startTag(null, "kml"); xmlSerializer.startTag(null, "Document");