Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of cslimrun
cslimrun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scm0sml
scm0sml

ASKER

this worked nicely:
xDS.XPath = "rss/channel/item[position() <= 4]"