getting the first 5 items in my xml datasource

I have the following on my .aspx:
<asp:XmlDataSource ID="xDS" runat="server"></asp:XmlDataSource>

I then have in my code behind:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim xmlDoc As New XmlDocument

            xmlDoc.Load("http://www.shponline.co.uk/incourt-content/-/journal/rss/10704/55813?doAsGroupId=10704&refererPlid=10708")

            xDS.Data = xmlDoc.OuterXml
            xDS.DataBind()
            xDS.XPath = "rss/channel/item"

            rptNews.DataSource = xDS
            rptNews.DataBind()
        End If
    End Sub

This works fine.

The only problem is that I only want to display the first 5 items.

Is there a simple way of doing this using the xmldatasource?
scm0smlAsked:
Who is Participating?
 
cslimrunConnect With a Mentor Commented:
you could try this:
xDS.XPath = "rss/channel/item[position() <= 5]"

or

load the xml into a dataset and use a dataview to filter down to just the top 5 rows.
0
 
scm0smlAuthor Commented:
this worked nicely:
xDS.XPath = "rss/channel/item[position() <= 4]"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.