SAX Parser error in Android

mtskqyvamn

New Member
I need to Parse XML file from server. Can Someone please help me. myCode :\[code\]public class XML2Parser extends Activity {TextView antonis1, antonis2, antonis3, tryans1, tryans2, tryans3;@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_xml2parser); findViewById(); String myurl = "http://www.playhard.cu.cc/tabel.xml"; new XMLParsing().execute(myurl); } private void findViewById() { // TODO Auto-generated method stub antonis1 = (TextView) findViewById(R.id.tvxml2pantonis1); antonis2 = (TextView) findViewById(R.id.tvxml2pantonis2); antonis3 = (TextView) findViewById(R.id.tvxml2pantonis3); tryans1 = (TextView) findViewById(R.id.tvxml2ptryans1); tryans2 = (TextView) findViewById(R.id.tvxml2ptryans2); tryans3 = (TextView) findViewById(R.id.tvxml2ptryans3); } public class XMLParsing extends AsyncTask<String,Void,String>{ @Override protected String doInBackground(String...url) { // TODO Auto-generated method stub try { String website = url.toString(); URL fullurl = new URL(website); // mengaktifkan parse pada xml reader SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); XML2ParserHandler Handler = new XML2ParserHandler(); xr.setContentHandler(Handler); InputSource is = new InputSource(fullurl.openStream()); xr.parse(is); String information = Handler.getInfo().toString(); return information; } catch (Exception e) { e.printStackTrace(); } String error = "error"; return error; } @Override protected void onPostExecute(String result) { // TODO Auto-generated method stub antonis1.setText(result); } }}\[/code\]Handler Class:\[code\]package com.projectx0001.antoni;import org.xml.sax.SAXException;import org.xml.sax.helpers.DefaultHandler;public class XML2ParserHandler extends DefaultHandler{ String testtext; public String getInfo(){ return testtext; } @Override public void startDocument() throws SAXException { // TODO Auto-generated method stub testtext = "It's Work Just Fine!"; super.startDocument(); }}\[/code\]LogCat:\[code\]01-19 14:53:00.700: D/dalvikvm(1953): GC_FOR_ALLOC freed 68K, 4% free 6685K/6915K, paused 40ms01-19 14:53:01.052: D/dalvikvm(1953): GC_FOR_ALLOC freed 1K, 4% free 7036K/7303K, paused 19ms01-19 14:53:01.114: E/MediaPlayer(1953): mOnVideoSizeChangedListener is null. Failed to send MEDIA_SET_VIDEO_SIZE message.01-19 14:53:01.114: E/MediaPlayer(1953): mOnPreparedListener is null. Failed to send MEDIA_PREPARED message.01-19 14:53:01.130: D/libEGL(1953): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so01-19 14:53:01.130: D/libEGL(1953): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so01-19 14:53:01.138: D/libEGL(1953): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so01-19 14:53:01.208: D/OpenGLRenderer(1953): Enabling debug mode 001-19 14:53:06.622: D/OpenGLRenderer(1953): Flushing caches (mode 0)01-19 14:53:08.271: W/System.err(1953): java.net.MalformedURLException: Protocol not found: [Ljava.lang.String;@413191b801-19 14:53:08.271: W/System.err(1953): at java.net.URL.<init>(URL.java:178)01-19 14:53:08.271: W/System.err(1953): at java.net.URL.<init>(URL.java:127)01-19 14:53:08.271: W/System.err(1953): at com.projectx0001.antoni.XML2Parser$XMLParsing.doInBackground(XML2Parser.java:54)01-19 14:53:08.271: W/System.err(1953): at com.projectx0001.antoni.XML2Parser$XMLParsing.doInBackground(XML2Parser.java:1)01-19 14:53:08.271: W/System.err(1953): at android.os.AsyncTask$2.call(AsyncTask.java:264)01-19 14:53:08.271: W/System.err(1953): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)01-19 14:53:08.271: W/System.err(1953): at java.util.concurrent.FutureTask.run(FutureTask.java:137)01-19 14:53:08.278: W/System.err(1953): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)01-19 14:53:08.278: W/System.err(1953): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)01-19 14:53:08.278: W/System.err(1953): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)01-19 14:53:08.278: W/System.err(1953): at java.lang.Thread.run(Thread.java:856)01-19 14:53:08.599: D/OpenGLRenderer(1953): Flushing caches (mode 0)\[/code\]
 
Back
Top