android - How to parse XML (Fogbugz XML API)? -


I am creating an Android application that connects to the fogbugs XML API (sends the request to the API, get the XML file back Does). Right now, I'm building a service that handles these requests, and parse everyone to access useful information. What would be the best way to do this? If I am getting input stream, should I use SAX Parser?

  DefaultHttpClient httpclient = New DefaultHttpClient (); HttpGet httpget = New HTTP Gate ("My URL that returns an XML file"); HTTP response response; Try {feedback = httpclient.execute (httpget); HttpEntity unit = response.getEntity (); InputStream stream = entity.getContent (); Buffer Redder Buffered = New Buffettder (new input streamer (stream)); String response string = ""; String floating; While ((temp = bufferedReader.readLine ())! = Tap) {responseString + = temp; } If (unit! = Null) {entity.consumeContent (); }} Catch (Client Protocol E) {// To-O Auto-Generated Catch Block e.printStackTrace (); } Grip (IOException E) {// TODO Auto-Generated Catch Block e.printStackTrace (); }  

I recommend that you use some XML DOM libraries like XOM or Dom4j Compared to SX events, you will find it very easy to work with tree structure. Personally, I use XM in Folkline - for the Fugabagus Eclipse plugin. You can pass the InputStream directly into your SAX / XOM / Dom4j parser, there is no need to create the first string. Also, make sure that you use the right encoding ... In this regard, your code is broken (when you pass intestust to your parser, then it is controlled by parser. (InputStream) create method.)

A fogbugge API signal ... When information is found about the case, and you get events (comments) Does not need Switch to move at all. To wit. Do not put events in the list of columns.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -