carrier.xml ile contains below xml contents
<?xml version="1.0" encoding="utf-8"?>
<carrier>
<vehicle>
<vehicle
cid="1"
cname="TAXI" />
<vehivle
cid="0"
cname="AUTO" />
</vehicle>
// In your code
XmlPullParser xpp=null;
int eventType = 0;
XmlPullParserFactory factory =null;
BufferedReader bufr=null;
StringBuilder total ="";
try{
bufr = new BufferedReader(new FileReader("/carrier.xml"));
total = new StringBuilder();
String line="";
while ((line = bufr.readLine()) != null)
{
total.append(line);
}
factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
xpp = factory.newPullParser();
xpp.setInput(new StringReader(new String(total)));
eventType = xpp.getEventType();
}catch(XmlPullParserException e){
// Log.v("xmlpullparser"," "+e);
e.printStackTrace();
}catch(IOException ie){
// Log.v("IOException"," "+ie);
ie.printStackTrace();
}
try{
while (eventType != XmlPullParser.END_DOCUMENT){
if(eventType == XmlPullParser.START_TAG){
String Scid="",Scname="";
int acount=xpp.getAttributeCount();
if(acount!=-1){
for(int x=0;x<acount;x++){
if(xpp.getAttributeName(x).equalsIgnoreCase("cid")){
Scid=xpp.getAttributeValue(x);
}if(xpp.getAttributeName(x).equals("cname")){
Scname=xpp.getAttributeValue(x);
}
}
}
}
eventType = xpp.next();
}
}catch(Exception e){
e.printStackTrace();
}
After this you can use the Scid Scname etc in your code as per your convenience