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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:05:11+00:00 2026-06-06T09:05:11+00:00

How do I consume my WordPress blog’s RSS feed to display my latest blog

  • 0

How do I consume my WordPress blog’s RSS feed to display my latest blog posts on my homepage? I ran into the following piece of code to do this:

  Function GetRSSFeed(strURL as String) as DataTable
    'Get the XML data
    Dim reader as XmlTextReader = New XmlTextReader(strURL)

    'return a new DataSet
    Dim ds as DataSet = New DataSet()
    ds.ReadXml(reader)    
    Return ds.Tables(2)
  End Function

But it errors out at this line: ‘ds.ReadXml(reader)’ with the following error:

A column named 'comments' already belongs to this DataTable.

Perhaps it doesn’t work since this code is from 2003? Does anyone have a working code sample? Many thanks in advance!

  • 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-06-06T09:05:13+00:00Added an answer on June 6, 2026 at 9:05 am

    You can use LINQ to XML to read a WordPress RSS feed.

    First get the feed. Make a Uri instance out of it.

    var rssFeed = new Uri("https://github.com/geersch/feed/");
    

    Then perform a GET request.

    var request = (HttpWebRequest) WebRequest.Create(rssFeed);
    request.Method = "GET";
    var response = (HttpWebResponse) request.GetResponse();
    

    Get the response stream and read it to download the contents of the feed.

    using (var reader = new StreamReader(response.GetResponseStream()))
    {
        var feedContents = reader.ReadToEnd();
        //...
    }
    

    Still within the above using statement use LINQ to XML to parse the downloaded content and extract the information you need.

    var document = XDocument.Parse(feedContents);
    
    var posts = (from p in document.Descendants("item")
                 select new
                 {
                     Title = p.Element("title").Value,
                     Link = p.Element("link").Value,
                     Comments = p.Element("comments").Value,
                     PubDate = DateTime.Parse(p.Element("pubDate").Value)
                 }).ToList();
    

    Now you can iterate over the results.

    foreach(var post in posts)
    {
        Console.WriteLine(post.Title);
        Console.WriteLine(post.Link);
        Console.WriteLine(post.Comments);
        Console.WriteLine(post.PubDate);
    }
    

    Here I just used an anonymous type to capture the output in, but feel free to create your own BlogPost class or something similar which you can use in the LINQ query.

    I’m used to C#, so that’s why I’ve used it in my reply. But you can easily convert it. There are some online converters which you can use.

    Regarding your issue with the DataSet (which I personally would not use to implement this), it is caused by an item (blog post) having nodes with the same name.

    For example:

    <comments>...</comments>
    <slash:comments>5</slash:comments>
    

    Sure the second one has a different namespace (slash), but DataSet’s ReadXml(…) method does not care about namespaces. It tries to create a second column named "comments". That is why you get the exception.

    You can still use a DataSet / DataTable if you want to. Just extract the data from the feed using LINQ to XML as shown above.

    Then create a DataSet and add a new table to it.

    var dataSet = new DataSet();
    var blog = new DataTable("Blog");
    blog.Columns.Add("Title", typeof(string));
    blog.Columns.Add("Link", typeof(string));
    blog.Columns.Add("Comments", typeof(string));
    dataSet.Tables.Add(blog);
    

    Iterate over the extracted data and add it to the DataTable:

    foreach (var post in posts)
    {
        var newRow = blog.NewRow();
        newRow["Title"] = post.Title;
        newRow["Link"] = post.Link;
        newRow["Comments"] = post.Comments;
    
        blog.Rows.Add(newRow);
     }
    

    Voila, we’ve now fixed your issue by no longer relying on the DataSet’s ReadXml(…) method. Download the feed, extract the data you are interested in and persist it.

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

Sidebar

Related Questions

I want to consume wordpress XMLRPC API for my latest experiment. Do you know
I am going to consume web service from android according to this link http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/
I'm trying to consume an IBM DataPower web service in WCF getting the following
I'm trying to consume a Java based SOAP web service from VBA code in
So I've run into a wall trying to crack why this WordPress install hogs
Im trying to consume Wcf from Android , my code private final static String
http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/ The above link taught me how to consume webservice in android its working
I am new to consume web service in android eclipse.Currently i am following the
I consume Java Service in my .NET appliaction. I have one question: When service
I want to consume a web service that is running on the local machine

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.