To generate an XML file using an XML serializer

Source: Internet
Author: User

Generating an XML file
    • Create a few virtual SMS objects that exist in list
    • Backup data is usually backed up to an SD card
Use StringBuffer to stitch strings
  • append all the nodes of the XML file into SB object

     sb.append ("<?xml version= ' 1.0 ' encoding= ' utf-8 ' standalone= ' yes '?> ');//Add SMSS Start node sb.append (" <smss> " );.......
  • Write SB into the output stream

    fos.write(sb.toString().getBytes());
To generate an XML file using an XML serializer
  • Get the XML Serializer object

     xmlserializer xs = Xml.newserializer ();  
  • Set the output stream to the serializer

    File file = new File(Environment.getExternalStorageDirectory(), "backupsms.xml");FileOutputStream fos = new FileOutputStream(file);//给序列化器指定好输出流xs.setOutput(fos, "utf-8");
  • To start generating an XML file

    xs.startDocument("utf-8", true);xs.startTag(null, "smss");xs.endTag(null, "smss");   ......   xs.endDocument();

To generate an XML file using an XML serializer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.