Exemplo n.º 1
0
        static async Task<XmlDocument> GetIndex()
        {
            var indexUrl = "http://www.w3.org/Graphics/SVG/Test/20110816/harness/htmlObjectApproved/index.html";
            var buffer = await Http.GetBufferAsync(new Uri(indexUrl));

            var doc = new XmlDocument();
            doc.LoadXmlFromBuffer(buffer, new XmlLoadSettings() { ProhibitDtd = false });

            return doc;
        }
        internal async Task<XmlDocument> LoadManifestAsync(string url)
        {
            Uri uri = null;
            IBuffer buffer = null;
            try
            {
                uri = new Uri(url);
            }
            catch
            {
#if DEBUG
                Logger.Log("Bad url: " + url);
#endif
                throw new Exception("Invalid URL");
            }

            buffer = await Downloader.DownloadBufferAsync(uri);

            if (buffer == null)
            {
#if DEBUG
                Logger.Log("Failed to get buffer of manifest");
#endif
                throw new Exception("Failed to get buffer from url");
            }
            XmlDocument document = new XmlDocument();

            try 
            {

                var bufferString = DataReader.FromBuffer(buffer).ReadString(buffer.Length);
                document.LoadXmlFromBuffer(buffer);
            }
            catch (Exception e)
            {
#if DEBUG
                Logger.Log("Failed to load XML from buffer = " + Logger.Display(e));
#endif
                throw new Exception("Invalid XML file");
            }

            return document;
        }