how to read xml properties value?

Posted by bala on Stack Overflow See other posts from Stack Overflow or by bala
Published on 2012-12-18T10:58:35Z Indexed on 2012/12/18 11:03 UTC
Read the original article Hit count: 225

Filed under:
|

I have xml file in sdcard(xxx.file) how to read all the xml tag properties values starting point to end point and prints that value please help me I am not familiar in xml pullparser please help me...

This is my xml file code:

<?xml version="1.0"?>
<layout schemaVersion="1" width="800" height="450" bgcolor="#000000">
<region id="47ff29524ce1b" width="800" height="450" top="0" left="0" userId="1">
<media id="9" type="image" duration="30" lkid="4" userId="1" schemaVersion="1">
<options><uri>9.png</uri></options>
 <raw/>
</media></region></layout>

java code:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try{
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser parser = factory.newPullParser();
        File file = new File(Environment.getExternalStorageDirectory()+ "/xxx.xml");

        FileInputStream fis = new FileInputStream(file);
        parser.setInput(new InputStreamReader(fis));

        }catch(XmlPullParserException e){

            e.printStackTrace();
        }catch(FileNotFoundException e){
            e.printStackTrace();
        }
    }
}

© Stack Overflow or respective owner

Related posts about android

Related posts about xml-parsing