• Increase font size
  • Default font size
  • Decrease font size
Home Development Linking to the TradePub XML database

Linking to the TradePub XML database

E-mail Print PDF

Here is a quick walkthrough for linking to the TradePub XML raw file source in a Visual Studio 2008 ASP.NET project. The steps are probably similar in other versions as well. Keep in mind that using this method, your page is pulling its data directly from the Tradepub XML url so you don’t have to update any local file. The performance seems to be slow some times, so in the future I will probably look at some caching options for the datasource in my website. If I find anything useful, I will update this post.

If you are reading this article and have no idea what TradePub is and why you would want to connect to its XML feed, don't worry. TradePub is a service for website owners to get paid to offer FREE business and technical eBooks and Magazines to your visitors. If you are interested, check them out here. If you don't have your own website but are interested in getting FREE eBooks and Magazines, you can go here.

  1. Add an XmlDataSource control to your page. Here is my configuration:
    • Data file is the RAW XML Link. You should replace with your link.(I blurred it out because I wasn't sure if that is public knowledge)
    • Xpath expression is how you specify what to read from the file. This expression is pulling the list of Publications that have a PubCategory element of ‘Infosoft’ or ’Inet’, because these are the only categories I want to show. If you don’t want to restrict categories, you can simply use the expression:

  2. After adding the XmlDataSource, configure caching to improve performance. Right click on the DataSource control and click 'properties'. Set 'EnableCaching' = True and 'CacheDuration'=86400. That will ensure your data is refreshed every 24 hours.

  3. Add a Datalist control to your page. Set the datasource to the XmlDataSource you created in step 1.

  4. I had to manually create the field bindings in the datalist. The code that binds the fields is in the Green box, and must be placed in the tags for your datalist control. This is just one possible way to use the data. Feel free to use this syntax to access other fields in the catalog. These are just the fields I wanted to use.

  5. You will have to work with the formatting to get your page to look nice, but here is the output from my site.
If you have any questions about this article, please visit my Software Development forum and post them!

Recommended Web Hosting

Free Stuff!

Featured FREE Resource:

Featured FREE Resource: