Code example for XmlSerializer

Methods: endTag, startTag

0
    PreferredActivity(XmlPullParser parser) throws XmlPullParserException, IOException {
        mPref = new PreferredComponent(this, parser);
    } 
 
    public void writeToXml(XmlSerializer serializer) throws IOException {
        mPref.writeToXml(serializer);
        serializer.startTag(null, "filter");
        super.writeToXml(serializer);
        serializer.endTag(null, "filter");
    } 
 
    public boolean onReadTag(String tagName, XmlPullParser parser) throws XmlPullParserException,
            IOException { 
        if (tagName.equals("filter")) {
            if (DEBUG_FILTERS) {
                Log.i(TAG, "Starting to parse filter...");
            } 
            readFromXml(parser);
            if (DEBUG_FILTERS) {
                Log.i(TAG, "Finished filter: depth=" + parser.getDepth() + " tag="
                        + parser.getName());