Solved

How do I determine if a Feed is RSS or Atom in .NET with C#?

Posted on 2011-02-18
4
754 Views
Last Modified: 2012-06-27
Hello,

I have a list of feeds that a user provides and I do not know in advance which feed is which (RSS or Atom).

I would like to figure out how to check which format each feed is because I'm running into issues where certain SyndicationItem item's are not assecible depending on the feed type.

For example,

((System.ServiceModel.Syndication.TextSyndicationContent)item.Content).Text

Works with Atom to pull off the Sumamry, but if I tried this for RSS I get an 'Object reference not set to an instance of an object' .error, but this then works:

item.Summary.Text

where 'item' for both is the variable name for the SyndicationItem

So, I need to check which type of feed I'm reading in to know which summary tag to use...

Thanks!!!!!!!!
0
Comment
Question by:stracqan
  • 2
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Brad Howe
ID: 34929304
Why not just use a quick XML Parser before loading it. I don't have time to write up a sample at the moment but you could determine based on xml key.

ATOM Feeds start with key <feed xmlns> </feed>

RSS Feed start with key <rss> </rss>

Cheers,
Hades666
0
 

Author Comment

by:stracqan
ID: 34929377
So before I run it through the SyndicationFeed check the XML that coming in from the web and pull out those values to determine which is which??

And then I would set a flag to know which item to use..?
0
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 34929402
Yep, that is what I would do.  First, take the raw xml as is, parse it and find those Keys.
Once you Key is found, run your feed with the appropriate tags.

cheers,
Hades666
0
 

Author Closing Comment

by:stracqan
ID: 34929417
thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Limiting string to two deciamls 18 32
String manipulation 15 49
index Out OF Range Exception error 4 29
Re-position the objects 7 50
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now