This is for 1 time

File newxmlfile = new File("/sdcard/new.xml");
         try{
              newxmlfile.createNewFile();
             }catch(IOException e){
              Log.e("IOException", "exception in createNewFile() method");
             }
             FileOutputStream fileos = null;       
             try{
              fileos = new FileOutputStream(newxmlfile);
             }catch(FileNotFoundException e){
              Log.e("FileNotFoundException", "can't create 
FileOutputStream");
             }
             XmlSerializer serializer = Xml.newSerializer();
             try {
            serializer.setOutput(fileos, "UTF-8");
            serializer.startDocument(null, Boolean.valueOf(true)); 
            
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output";, 
true); 
            serializer.startTag(null, "root"); 
            serializer.startTag(null, "city");
            serializer.startTag(null, data.getCity());
  serializer.endTag(null, data.getCity());
  serializer.endTag(null, "city");
  serializer.startTag(null, "temperature");
  serializer.attribute(null, "temperature", 
data.getCurrentConditionData().getTemp_c()); 
serializer.endTag(null, "temperature");
serializer.endTag(null, "root");
serializer.endDocument();
serializer.flush();
fileos.close();
             }catch(Exception e)
             {
             Log.e("Exception","error occurred while creating xml file"); 
             }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to