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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:23:56+00:00 2026-05-23T16:23:56+00:00

This is my XML structure, which is a list of events that each contains

  • 0

This is my XML structure, which is a list of events that each contains a list of event times. I need to return a list of ‘TIME’ values, but im stuck on how to get these values (Note that I need to query this list & filter by ‘Id’)

enter image description here

Code so far:

public IEnumerable<EventFeed> GetEventDatesByEventId(int eventId)
    {
        return (from feed in xmlDoc.Descendants("Event")
                where (int)feed.Element("Id") == eventId
                from ev in feed.Elements("Times")
                select new EventFeed()
                {
                    EventDate = (DateTime)ev.Element("Time")
                }).ToList().OrderByDescending(x => x.EventDate);
    }

thanks
kb

  • 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-23T16:23:57+00:00Added an answer on May 23, 2026 at 4:23 pm

    Close, you’ll need to select the <Times> node first or use Descendants since <Time> is below EventTime:

    return (from feed in xmlDoc.Descendants("Event")
            where (int)feed.Element("Id") == eventId
            from et in feed.Element("Times").Elements("EventTime")
            select new EventFeed()
            {
                EventDate = (DateTime)et.Element("Time")
            }).ToList().OrderByDescending(x => x.EventDate);
    

    Sample:

    string xml = @"<?xml version=""1.0"" ?>
    <Events>
        <Event>
            <Id>542</Id>
            <Times>
                <EventTime>
                    <Time>2011-11-28T14:00:00</Time>
                </EventTime>
                <EventTime>
                    <Time>2011-11-30T10:00:00</Time>
                </EventTime>
                <EventTime>
                    <Time>2011-11-30T09:00:00</Time>
                </EventTime>
            </Times>
        </Event>
    </Events>";
    
    int eventId = 542;
    foreach (var evt in GetEvents(XDocument.Parse(xml), eventId)
    {
        Console.WriteLine("{0}", evt.EventDate);
    }
    

    Outputs:

    11/30/2011 10:00:00
    11/30/2011 09:00:00
    11/28/2011 14:00:00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file that contains a structure.. In this structure, I have
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have a List<string> sampleList which contains Data1 Data2 Data3... The file structure is
I have an XML configuration file that contains a list of documents with field
This is a xml structure that I want to parse using libxml parsing. How
I have a XML Structure that looks like this. <sales> <item name=Games sku=MIC28306200 iCat=28
my xml structure looks like this: <entity id=1000070> <name>apple</name> <type>category</type> <entities> <entity id=7002870> <name>mac</name>
Given an XML structure like this: <garage> <car>Firebird</car> <car>Altima</car> <car>Prius</car> </garage> I want to
Given an xml structure like this <gesmes:Envelope> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender>
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five

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.