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 1033493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:14:26+00:00 2026-05-16T14:14:26+00:00

I am reading an rss feed and I am binding it to a repeater.

  • 0

I am reading an rss feed and I am binding it to a repeater. I would like to select the 3 most recent posts. in my XPathExpression I use AddSort The data are sorted just fine but when I bind to the repeater the sort is lost.

That is my first issue. I am using xpath expression [position()<=3] to limit to 3 items. This, however, occurs prior to the sort. So, I would not be getting the 3 most recent records but rather the first three from the feed which are then sorted (if I get the sorting working properly with the repeater). Here is a code snippet. Any help would be appreciated.

            Dim xpn As XPathNavigator = New XPathDocument(RssURL).CreateNavigator
        _xmlnsm = XmlHelper.GetXmlNameSpaceManager(xpn)
        Dim expr As XPathExpression
        expr = xpn.Compile(String.Format("/rss/channel/item[position()<={0}]", numRecords))
        expr.AddSort("title", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Text)

        Dim iterator As XPathNodeIterator = xpn.Select(expr.Expression, _xmlnsm)
        rptNews.DataSource = iterator
        rptNews.DataBind()
  • 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. Editorial Team
    Editorial Team
    2026-05-16T14:14:26+00:00Added an answer on May 16, 2026 at 2:14 pm

    I don’t think my solution is ideal, but here it is:

    I created a new DataTable and added a column for each SingleNode in the XML. I populated an XPathNodeIterator like I did before and then looped through it to create each new row of the DataTable. Then I applied a sort to the DefaultView of the DataTable. Then I did ANOTHER loop – this one was of the now-populated DefaultView. I used a counter in the loop. If the counter was greater than my desired number of records, I used Rows.RemoveAt. Finally, I returned the DataTable and bound it to the repeater.

    I don’t like it. It feels like I am doing way too much extra work here. But… it is giving the desired result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am reading an RSS feed from a third party and then import data
I'm Reading many rss feed and store these data in database in my site.
When reading my RSS feed with the Thunderbird feed reader, some entries are duplicated.
I am reading a RSS feed into nsmutablearray. i want to search the xml
$fp = fopen(http://feeds.reuters.com/Reuters/PoliticsNews?format=xml,r) or die(Error reading RSS data.); The above coding working correctly in
from a PHP script I'm downloading a RSS feed like: $fp = fopen('http://news.google.es/news?cf=all&ned=es_ve&hl=es&output=rss','r') or
I saw this article pop-up in my MSDN RSS feed, and after reading through
I'm reading a rss feed and I get an image url and now I
I'm reading a rss feed from $homepage = file_get_contents('http://feeds.cbsnews.com/CBSNewsWorld'); $movies = new SimpleXMLElement($homepage); and
I'm reading a rss feed using simple code: <?php $homepage = file_get_contents('http://www.forbes.com/news/index.xml'); $movies =

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.