Hi everyone,

i need Your help:

i need to read a XML output from  server (who needs username and 
password for access)   in my android app. I've made HttpConnection (post 
to the server was no problem..) 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();
               }
    }
What can i do?
any help is welcome!
thanks
dey


--~--~---------~--~----~------------~-------~--~----~
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]
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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to