Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting rss feeds

Status
Not open for further replies.

jshurst

Programmer
Oct 27, 2004
1,158
US
I am currently using the xmlDataSource to capture rss feeds from a couple of sites. This works fine for returning all of the information. I am displaying the results in a datalist. I would like to limit what I am displaying to the 5 records from the rss feed. Does anyone know what would be the easiest way to do this?

Thanks,

J
 
The best way would probably be to edit the data source itself and delete all entries after the first 5.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Can you suggest how I do that? I'm using the xmlDataSource, so I don't really know how to edit the information (if that is the "source" you are refering to). This is the first time I've used this type datasource (in 2.0), but I guess I may could save it to a dataset and then delete all the rows after row 4. Don't really know if that is good, or possible though.
 
Sorry, I forgot I hadn't replied to this thread.

One way of limiting the data source would be to use the XPath property. Say, for example, we had the following XML File:
Code:
<Employees>
  <Employee FirstName="Tom" LastName="Jones" CustomerId="1" />
  <Employee FirstName="John" LastName="Doe" CustomerId="2" />
  <Employee FirstName="Peter" LastName="Smith" CustomerId="3" />
  <Employee FirstName="Paul" LastName="Campbell" CustomerId="4" />
  <Employee FirstName="Frank" LastName="White" CustomerId="5" />
</Employees>
Then, we could us XPath to only show the records where ther CustomerID is less than or equal to 3 e.g.
Code:
        'Declarations
        Dim xmlDS As New XmlDataSource

        ' Set the datasource 
        xmlDS.DataFile = "myXML.xml"

        ' Limit the datasource to only show the first 3 records
        xmlDS.XPath = "Employees/Employee[@CustomerId<='3']"

        ' Bind a control to the "limited" datasource
        GridView1.DataSource = xmlDS
        GridView1.DataBind()


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top