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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:56:00+00:00 2026-05-17T20:56:00+00:00

http://www.dreamincode.net/forums/xml.php?showuser=335389 Given the XML above, how can I iterate through each element inside of

  • 0

http://www.dreamincode.net/forums/xml.php?showuser=335389

Given the XML above, how can I iterate through each element inside of the ‘lastvisitors’ element, given that each child group is the same with just different values?

//Load latest visitors.
var visitorXML = xml.Element("ipb").Element("profile").Element("latestvisitors");

So now I have captured the XElement containing everything I need. Is there a way to loop through the elements to get what I need?

I have this POCO object called Visitor whose only purpose is to hold the necesary information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpDIC.Entities
{
    public class Visitor
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Url { get; set; }
        public string Photo { get; set; }
        public string Visited { get; set; }
    }
}

Thanks again for the help.

  • 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-05-17T20:56:01+00:00Added an answer on May 17, 2026 at 8:56 pm

    You can probably just do something like this in Linq:

    XDocument xml = XDocument.Parse(xmlString);
    var visitors = (from visitor in xml.Descendants("latestvisitors").Descendants("user")
                    select new Visitor() {
                      ID = visitor.Element("id").Value,
                      Name = visitor.Element("name").Value,
                      Url = visitor.Element("url").Value,
                      Photo = visitor.Element("photo").Value,
                      Visited = visitor.Element("visited").Value
                    });
    

    The only caveat here is that I didn’t do any null checking.

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

Sidebar

Related Questions

Given this URL: http://www.dreamincode.net/forums/xml.php?showuser=1253 How can I download the resulting XML file and have
From this XML response: http://www.dreamincode.net/forums/xml.php?showuser=335389 I want to grab all of the users friends.
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
I'm trying to implement sqldependency in my vb.net application as per: http://www.dreamincode.net/forums/topic/156991-using-sqldependency-to-monitor-sql-database-changes/ I'm having
I found this: http://www.evolt.org/failover-database-connection-with-php-mysql and similar examples. But is there a better way? I
http://www.codeplex.com/IIRF/Thread/List.aspx My webhost installed IIRF for me and I am convinced that they did
From http://www.jibbering.com/faq/faq_notes/closures.html : Note: ECMAScript defines an internal [[prototype]] property of the internal Object
From http://www.faqs.org/rfcs/rfc2822.html : CR and LF MUST only occur together as CRLF; they MUST
I decided to try http://www.screwturn.eu/ wiki as a code snippet storage utility. So far
This web page http://www.w3schools.com/ASP/prop_sessionid.asp states that a session ID is generated on the ServerSide.

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.