Solved

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

Posted on 2011-02-18
4
805 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

690 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