Ejemplo n.º 1
0
        //---------------------------------------------------------//

        //---------------------------------------------------------//
        //---       PARSING XML STRING TO CLASS OBJECT          ---//
        //---------------------------------------------------------//
        private mobAppModel ParseXmlData(string s)
        {
            XmlSerializer xs = new XmlSerializer(typeof(mobAppModel));
            mobAppModel   ai = (mobAppModel)xs.Deserialize(new StringReader(s));

            return(ai);
        }
Ejemplo n.º 2
0
        // Helper methods
        //---------------------------------------------------------//
        //---               DOWNLOAD DATA FROM XML              ---//
        //---------------------------------------------------------//
        public async Task GetData()
        {
            // Get xml data from URL
            HttpClient          hc       = new HttpClient();
            HttpResponseMessage response = await hc.GetAsync("https://dl.dropboxusercontent.com/s/y2e6s4v2f67zfq1/xmlData.xml");



            // Check if the data is downloaded successfully
            if (response.IsSuccessStatusCode)
            {
                // Put the xml data into string
                string s = await response.Content.ReadAsStringAsync();

                // Check if the data is transfered to string
                if (response.Content.ReadAsStringAsync().IsCompleted)
                {
                    // Parse xml data
                    allApps = ParseXmlData(s);
                }
            }
            else                    // If any error occurs while downloading data
            {
                throw new Exception("Unable to communicate with server...");
            }
            // Message to display to the user
        }