XMLLib
In our library (sandra.libs.util.xmllib
in the code bundle), the RetrieveXMLTask
(see RetrieveXMLTask.java
) is responsible for fetching an XML file from the web and saving its content in a String to be further processed. It is declared in the following way:
class RetrieveXMLTask extends AsyncTask<String, Void, String>
It has been defined as an asynchronous task (AsyncTask
) that receives a collection of Strings as input parameters. It does not produce any type of progress values (void), and produces a String as a result of the background computation (<parameters, progress, result>). In our case, the String input is the URL to retrieve the XML file, and the String result is the XML code in the file. The reading of the XML file from the specified URL is done as a background task in the doInBackground
method that uses other private methods that open the HTTP connection and read the byte streams (saveXmlInString
and readStream
). Take a look at the doInBackground
and saveXMLInString...