Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 150233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:15:29+00:00 2026-05-11T09:15:29+00:00

I have the following rss feed which I would like to query to get

  • 0

I have the following rss feed which I would like to query to get all the items with a specific category named subchannel. So far I only managed to get to the first element, but only if it is the first in the list. How would I write the linq query to filter the rss feed to only show items where a certain ‘subchannel’ matches a specific value eg. ‘Accuracy’?

cheers, Chris

protected void Filter() {     var feeds = (from item in doc.Descendants('item')                  where                  item.CategoryValue('Channel') == 'Accomplishment'                   select new                  {                      Title = item.Element('title').Value,                      rssGuid = item.Element('guid').Value,                      description = item.Element('description').Value,                      link = item.Element('link').Value                   }).ToList();      ListView1.DataSource = feeds;     ListView1.DataBind();  } 

Extension Method

public static class ccExtensions {     public static string CategoryValue(this XElement item, string type)     {            var category = item.Elements('category').FirstOrDefault(c => (string)c.Attribute('domain') == type           && !string.IsNullOrEmpty(c.Value));          return category == null ? null : category.Value;      } } 

RSS extract

<item>             <title>Time Mgmt</title>             <description>The following is a list of sample values</description>             <link>http://blah.com/test.aspx</link>             <category domain='Channel'></category>             <category domain='Channel'>Goals</category>             <category domain='SubChannel'></category>             <category domain='SubChannel'>Accountability</category>             <category domain='SubChannel'>Accomplishment</category>             <category domain='SubChannel'>Achievement</category>             <category domain='SubChannel'>Accuracy</category>             <category domain='SubChannel'>Agility</category>             <category domain='SubChannel'>Ambition</category>             <category domain='SubChannel'>Anticipation</category>             <category domain='SubChannel'>Appreciation</category>             <category domain='SubChannel'>Assertiveness</category>             <category domain='SubChannel'>Beauty</category>             <category domain='Type'></category>             <category domain='Type'>Time Management</category>             <guid>5e993951-da49-400b-b8d4-68b95628b9d5</guid> </item> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:15:29+00:00Added an answer on May 11, 2026 at 9:15 am

    The problem is that your CategoryValue is returning a single string, despite the fact that you have multiple categories. I suggest you change it to:

    public static class ccExtensions {     public static IEnumerable<string> Categories(this XElement item,                                                  string type)     {         return from category in item.Elements('category')                where (string) category.Attribute('domain') == type                      && !string.IsNullOrEmpty(category.Value)                select category.Value;     } } 

    then change your query to:

    from item in doc.Descendants('item') where item.Categories('SubChannel').Contains('Accomplishment') select ... 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an rss feed which i would like to read from in my
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
Is it possible to extract items from an RSS feed, such as the following:
I have an RSS Feed class, which holds the feed url, name, etc. and
I have the following code to parse an RSS feed: $doc = new DOMDocument();
I have the following data being generated from a google spreadsheet rss feed. いきます,go,5
I have the following code that converts my twitter account rss feed into a
I have the following xml that I would like to read: chinese xml -
I have the following xml <rss> <channel> <item><title><![CDATA[bla]]></title><description><![CDATA[desc1]]></description><link>blah</link></item> <item><title><![CDATA[bleh]]></title><description><![CDATA[desc2]]></description><link>blahhh</link></item> </rss> </channel> I want to
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.