Parsing local xml file in android

后端 未结 4 1588
轮回少年
轮回少年 2021-01-29 00:50

Hii every one, am brand new to android,i have a doubt can any one help me

In this following link

http://www.androidpeople.com/android-xml-parsing-tutorial-using

4条回答
  •  天命终不由人
    2021-01-29 01:07

    try {
    //          InputStream is = getResources().getAssets().open("yourfilename.xml");
                InputStream is =getAssets().open("yourfilename.xml");
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
    
                MyXMLHandler myXMLHandler = new MyXMLHandler();
                xr.setContentHandler(myXMLHandler);
    
                xr.parse(new InputSource(is));
    
            } catch (Exception e) {
                System.out.println("XML Pasing Excpetion = " + e);
            }
    

提交回复
热议问题