Code example for XmlPullParser

Methods: getAttributeValue, getName, getText, next, nextTag, require

0
     */ 
    private void readChangeLogRowNode(XmlPullParser parser, ChangeLog changeLog,String versionName) throws  Exception{
 
        if (parser==null) return;
 
        parser.require(XmlPullParser.START_TAG, null,TAG_CHANGELOGTEXT);
 
        String tag = parser.getName();
        if (tag.equals(TAG_CHANGELOGTEXT)){
            ChangeLogRow row=new ChangeLogRow();
            row.setVersionName(versionName);
 
            // Read attributes 
            String changeLogTextTitle=parser.getAttributeValue(null,ATTRIBUTE_CHANGETEXTTITLE);
            if (changeLogTextTitle!=null)
                row.setChangeTextTitle(changeLogTextTitle);
 
            // It is possible to force bulleted List 
            String bulletedList = parser.getAttributeValue(null, ATTRIBUTE_BULLETEDLIST);
            if (bulletedList!=null){
                if (bulletedList.equals("true")){
                    row.setBulletedList(true);
                }else{ 
                    row.setBulletedList(false);
                } 
            }else{ 
                row.setBulletedList(super.bulletedList);
            } 
 
            // Read text 
            if (parser.next() == XmlPullParser.TEXT) {
                String changeLogText=parser.getText();
                if (changeLogText==null)
                    throw new ChangeLogException("ChangeLogText required in changeLogText node"); 
                row.parseChangeText(changeLogText);
                parser.nextTag();
            } 
            changeLog.addRow(row);
 
            Log.d(TAG,"Added row:"+row.toString());
        } 
        parser.require(XmlPullParser.END_TAG, null,TAG_CHANGELOGTEXT);
    } 
 
}