[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2011-02-18
4
Medium Priority
?
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

650 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