void usePullParse(){
  try {
    LitePalAttr litePalAttr=LitePalAttr.getInstance();
    XmlPullParserFactory factory=XmlPullParserFactory.newInstance();
    XmlPullParser xmlPullParser=factory.newPullParser();
    xmlPullParser.setInput(getConfigInputStream(),"UTF-8");
    int eventType=xmlPullParser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
      String nodeName=xmlPullParser.getName();
switch (eventType) {
case XmlPullParser.START_TAG:
{
          if (NODE_DB_NAME.equals(nodeName)) {
            String dbName=xmlPullParser.getAttributeValue("",ATTR_VALUE);
            litePalAttr.setDbName(dbName);
          }
 else           if (NODE_VERSION.equals(nodeName)) {
            String version=xmlPullParser.getAttributeValue("",ATTR_VALUE);
            litePalAttr.setVersion(Integer.parseInt(version));
          }
 else           if (NODE_MAPPING.equals(nodeName)) {
            String className=xmlPullParser.getAttributeValue("",ATTR_CLASS);
            litePalAttr.addClassName(className);
          }
 else           if (NODE_CASES.equals(nodeName)) {
            String cases=xmlPullParser.getAttributeValue("",ATTR_VALUE);
            litePalAttr.setCases(cases);
          }
          break;
        }
default :
      break;
  }
  eventType=xmlPullParser.next();
}
}
 catch (XmlPullParserException e) {
throw new ParseConfigurationFileException(ParseConfigurationFileException.FILE_FORMAT_IS_NOT_CORRECT);
}
catch (IOException e) {
throw new ParseConfigurationFileException(ParseConfigurationFileException.IO_EXCEPTION);
}
}

void usePullParse ( ) { try { LitePalAttr litePalAttr = LitePalAttr . getInstance ( ) ; XmlPullParserFactory factory = XmlPullParserFactory . newInstance ( ) ; XmlPullParser xmlPullParser = factory . newPullParser ( ) ; xmlPullParser . setInput ( getConfigInputStream ( ) , "UTF-8" ) ; int eventType = xmlPullParser . getEventType ( ) ; while ( eventType != XmlPullParser . END_DOCUMENT ) { String nodeName = xmlPullParser . getName ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : { if ( NODE_DB_NAME . equals ( nodeName ) ) { String dbName = xmlPullParser . getAttributeValue ( "" , ATTR_VALUE ) ; litePalAttr . setDbName ( dbName ) ; } else if ( NODE_VERSION . equals ( nodeName ) ) { String version = xmlPullParser . getAttributeValue ( "" , ATTR_VALUE ) ; litePalAttr . setVersion ( Integer . parseInt ( version ) ) ; } else if ( NODE_MAPPING . equals ( nodeName ) ) { String className = xmlPullParser . getAttributeValue ( "" , ATTR_CLASS ) ; litePalAttr . addClassName ( className ) ; } else if ( NODE_CASES . equals ( nodeName ) ) { String cases = xmlPullParser . getAttributeValue ( "" , ATTR_VALUE ) ; litePalAttr . setCases ( cases ) ; } break ; } default : break ; } eventType = xmlPullParser . next ( ) ; } } catch ( XmlPullParserException e ) { throw new ParseConfigurationFileException ( ParseConfigurationFileException . FILE_FORMAT_IS_NOT_CORRECT ) ; } catch ( IOException e ) { throw new ParseConfigurationFileException ( ParseConfigurationFileException . IO_EXCEPTION ) ; } }
use xmlpullparser to parse the litepal . xml file . it will store the result in the instance of litepalattr . note while analyzing litepal . xml file , parseconfigurationfileexception could be thrown . be careful of writing litepal . xml file , or developer ' s application may be crash .
