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

  • Home
  • SEARCH
  • 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 8292785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:35:46+00:00 2026-06-08T13:35:46+00:00

I know its a lot code… sorry for that….my list class is like this..

  • 0

I know its a lot code… sorry for that….my list class is like this..

public class XMLList
{
    public string Title { get; set; }
    [DataMember]
    public string Link { get; set; }
    [DataMember]
    public DateTime pubDate { get; set; }
    [DataMember]
    public string dcCreator { get; set; }
    [DataMember]
    public string GUID { get; set; }
    [DataMember]
    public Int32 wpPostId { get; set; }
    [DataMember]
    public string wpStatus { get; set; }
    [DataMember]
    public Int32 wpMenuOrd { get; set; }
    [DataMember]
    public string Category { get; set; }
    [DataMember]
    public List<Comment> Comments { get; set; }
}

public class Comment
{
    [DataMember]
    public Int32 wpCmtId { get; set; }
    [DataMember]
    public string wpCmtAuthor { get; set; }
    [DataMember]
    public string wpCmtAuthorEmail { get; set; }
    [DataMember]
    public string wpCmtAuthorURL { get; set; }
    [DataMember]
    public Int64 wpCmtAuthorIP { get; set; }
    [DataMember]
    public DateTime wpCmtAuthorDate { get; set; }
}

my c# code is like this

XmlDocument doc = new XmlDocument();
doc.Load(@"xml\willowcreekassociationblog.wordpress.xml");
//Get Channel Node
XmlNode channelNode = doc.SelectSingleNode("rss/channel");
if (channelNode != null)
{
    //Add NameSpace
    XmlNamespaceManager nameSpace = new XmlNamespaceManager(doc.NameTable);
    nameSpace.AddNamespace("excerpt", "http://wordpress.org/export/1.2/excerpt/");
    nameSpace.AddNamespace("content", "http://purl.org/rss/1.0/modules/content/");
    nameSpace.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
    nameSpace.AddNamespace("wfw", "http://wellformedweb.org/CommentAPI/");
    nameSpace.AddNamespace("wp", "http://wordpress.org/export/1.2/");

    //Parse each item
    foreach (XmlNode itemNode in channelNode.SelectNodes("item"))
    {
        objrssItem.Add(rssItem);
        rssItem.GUID = itemNode.SelectSingleNode("guid").InnerText;
        rssItem.Title = itemNode.SelectSingleNode("title").InnerText;
        rssItem.dcCreator = itemNode.SelectSingleNode("dc:creator", nameSpace).InnerText;
        rssItem.Link = itemNode.SelectSingleNode("link").InnerText;
        rssItem.pubDate = DateTime.Parse(itemNode.SelectSingleNode("pubDate").InnerText);
        rssItem.ContentEncoded = itemNode.SelectSingleNode("content:encoded", nameSpace).InnerText;

        XmlNode cNode = doc.SelectSingleNode("rss/channel/item");
        foreach (XmlNode commentNode in cNode.SelectNodes("wp:comment", nameSpace))
        {
           //rssItem.Comments = Comments
            rsscomment.wpCmtId = Convert.ToInt32(commentNode.SelectSingleNode("wp:comment_id", nameSpace).InnerText);
            rsscomment.wpCmtAuthor = commentNode.SelectSingleNode("wp:comment_author", nameSpace).InnerText;
            rsscomment.wpCmtContent = commentNode.SelectSingleNode("wp:comment_content", nameSpace).InnerText;  
        }
    }
    oXMLListResult.listOfXMLResult = objrssItem;
}

i have xml like enter link description here

when I am trying to read for each item in channel with xmlnode and its working fine. and each item has multiple comments which trying to achieve by using foreach inside foreach. But wp:comment foreach item its not working. What am i doing wrong? I did some google but no luck.

Thanks.

  • 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-08T13:35:47+00:00Added an answer on June 8, 2026 at 1:35 pm
    XmlNode cNode = doc.SelectSingleNode("rss/channel/item");
    

    This is resetting your item enumeration to the beginning, which would cause every item to have identical comments.

    EDIT:
    I believe this is the easiest way to fix the problem I mentioned. By searching below the already selected node, you avoid the repetition. Note that cNode is no longer required.

    foreach (XmlNode commentNode in itemNode.SelectNodes("wp:comment", nameSpace))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In short I have code like this. I know its bad style but have
I know its possible to create activities by doing something like the code bellow,
While I code in Visual Studio, I have lot of &nbsp; I know its
While I code in Visual Studio, I have lot of &nbsp; I know its
I know that it's a subject that can raise a lot of debate, but
I know its possible to accept a list of objects as a parameter thanks
I know its impossible for 100% protection, but something high or that works for
I have a DropDownList and need to know its name in the code behind:
Here's my wild and whacky psuedo-code. Anyone know how to make this real? Background:
I know this question would have run across in the minds a lot of

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.