0

my code :

XmlDocument xml1 = new XmlDocument();
        XmlDocument xml2 = new XmlDocument();
        xml1.Load("http://www.oztivo.net/xmltv/FMDRA_2013-05-31.xml.gz");
        xml2.Load("http://www.oztivo.net/xmltv/GEM-ACT_2013-05-16.xml.gz");

my problem is that on page load for first time everything work great but on the refresh it's giving me an error :

'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.

Do anyone know how to fix this issue ?

4
  • 2
    Your URL is for a gzipped version file. You'd need to decompress that first... or remove the .gz part from the URL. Commented May 28, 2013 at 11:39
  • and how should i decompress it ? Commented May 28, 2013 at 11:41
  • @samer like this: dotnetperls.com/decompress Commented May 28, 2013 at 11:41
  • i want to set url and return xml file Commented May 28, 2013 at 12:03

1 Answer 1

1

You can use HttpWebRequest and the AutomaticDecompression property to automatically decompress the 'gziped' file:

HttpWebRequest request = HttpWebRequest.CreateHttp("http://www.oztivo.net/xmltv/FMDRA_2013-05-31.xml.gz");
request.AutomaticDecompression = DecompressionMethods.GZip;

WebResponse response = request.GetResponse();

XmlDocument xml1 = new XmlDocument();
xml1.Load(response.GetResponseStream());

[Update] Note :

In fact, when testing your urls we can see that they are 'gziped'. If you try to access the urls from a web browser you will see the XML content displayed because the web browser decompress the content.

[Update2] CreateHttp is available from .NET 4 or later. You can do (HttpWebRequest)WebRequest.Create instead if working with .NET < .NET 4

Sign up to request clarification or add additional context in comments.

2 Comments

it giving me an error on CreateHttp as the function do not exist
CreateHttp is available from .NET 4 or later. You can do (HttpWebRequest)WebRequest.Create instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.