Hi everyone.
I try to parser XML file using SAX parser. Can you help me.?
Above is some line code i think it not correct. Someone can check for
me, please:


try{
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                xmlHandler myXMLHandler = new xmlHandler();
                try{
                        File fxml = new File("/mnt/sdcard/myXML.xml");
                        fxml.getName(); // test file null
                        try{
                                sp.parse(fxml,myXMLHandler);
                        }catch (Exception e) {
                                        // TODO: handle exception
                                Log.e("ERROR","Can not parser file 
xml"+e.toString());
                                }
                }catch (Exception e) {
                                // TODO: handle exception
                        Log.e("ERROR","Can not new file xml from source");
                        }


                /** Get result from MyXMLHandler ebook Object */
                ebook = xmlHandler.getEbook();

                /** Create handler to handle XML Tags ( extends
DefaultHandler ) */

        }catch (Exception e) {
                        // TODO: handle exception
                Log.e("ERROR","Error parser file");
                }
        try{
                String author= ebook.getAuthor();
                EditText txtEdit = (EditText) findViewById(R.id.editText1);
                txtEdit.setText(author);
        }catch (Exception e) {
                        // TODO: handle exception
                Log.e("ERROR","Ebook can not get author");
                }
    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to