tags:

views:

15

answers:

2

As part of our application, we need to download a RSS feed. Our client's have an internal RSS feed which works fine with IE/Firefox but doesn't work with our application.

The application try to download from a url. I am not sure what exactly wrong here:

RssChannelDom DownloadChannelDom(string url)
{
    RssChannelDom dom = null;

    System.Net.Cache.RequestCachePolicy policy =
        new System.Net.Cache.RequestCachePolicy(
            System.Net.Cache.RequestCacheLevel.BypassCache);

        WebClient client = new WebClient();
        client.CachePolicy = policy;
        client.Headers.Add("User-Agent", "Mozilla/4.0");
        byte[] feed = client.DownloadData(url);

        // parse it as XML
        XmlDocument doc = new XmlDocument();

        doc.Load(new MemoryStream(feed));

        return dom;
}

The client URL looks like:

http://sampleclient/diapatents/index.php/Special:Ask/
    -5B-5BCategory:Patent_Alert
    -5D-5D-20-5B-5BResearch-20Unit::Allergy_and_Respiratory
    -5D-5D-20-5B-5BOrganisation::
    -5D-5D-20-5B-5BTarget::
    -5D-5D-20-5B-5BIndication::
    -5D-5D-20-5B-5BDate::
    -20-3E-20-0A-5D-5D-20-5B-5BRevised-20Since::
    -20-3E-20-0A2009-2D8-5D-5D/sort-3DDate/order-3DDESC/
    format-3Drss/rsstitle%3DPfizerpediaPatents/rssdescription-3DRSS-20Feed:
    -20Allergy-20and-20Respiratory-20recently-20uploaded-20or-20revised/
    limit%3D400
A: 

You aren't really specifying what the problem is. You need to be more specific in indicating how your program is failing.

That being said, I would check the following:

  • See what the HTTP result code is. It should be 200. If it is not, then it might indicate that you have submitted a malformed request.
  • If the HTTP result code is 200, then take a look at the actual contents of the stream coming back. Is it even XML, or is it something else that might indicate the error?
casperOne
+1  A: 

You are always returning null since you don't do anything with the dom variable that you're returning.

svinto