Hi all,

i need Your help:

i become XML output from  server (who needs username and password for 
access)  and i d like to read the information in my android app. I've 
made HttpConnection to connect the server and authenticate. Then i read 
the HttpResponse - it looks like this:

private void getResponse() {
        try {
             //huc ist the HttpURLConnection

            StringBuffer sb = new StringBuffer(huc.getContentLength());
            InputStreamReader isr = new 
InputStreamReader(huc.getInputStream(),"UTF-8");
            char buff[] = new char[huc.getContentLength()];
            int n;
            while ((n = isr.read(buff, 0, huc.getContentLength() - 1)) > 
0) {
                sb.append(buff, 0, n);
            }
            response = sb.toString();  //as String is easy ...  but with 
the xml elements ... see next:
            isr.close();
           
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        try {
               //now i need to parse this output into Array only with 
the attributs from the
               XMLHandler h = new XMLHandler();
               SAXParserFactory f = SAXParserFactory.newInstance();
               SAXParser sp = f.newSAXParser();
               XMLReader xr = sp.getXMLReader();
               xr.setContentHandler(h);
               sp.parse(huc.getInputStream(), h);  // here is my 
problem: parse does not support Stream input ..
    
              }

           catch (SAXParseException error) {

               Log.d("\nParse Error", "\n Num: " + error.getLineNumber());
               Log.d("\n", error.getMessage() );
               }catch (Throwable t) {
               t.printStackTrace();
               }
    }

any help is welcome!
thanks
dey


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to