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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:55:53+00:00 2026-05-28T00:55:53+00:00

<?xml version=1.0 encoding=utf-8 ?> <reportgroups> <Reportgroup id=1 name=reportGroup1> <report id=1 name=report1 isSheduled=false></report> <report id=2

  • 0
<?xml version="1.0" encoding="utf-8" ?>
<reportgroups>
  <Reportgroup id="1" name="reportGroup1">
    <report id="1" name="report1" isSheduled="false"></report>
    <report id="2" name="report2"  isSheduled="false"></report>
    <report id="3" name="report3"  isSheduled="false"></report>
  </Reportgroup>
  <Reportgroup id="2" name="reportGrouop2">
    <report id="4" name="report4"  isSheduled="false"></report>
  </Reportgroup>
  <Reportgroup id="3" name="reportGrouop3"></Reportgroup>
</reportgroups>

and i have classes

public class Reportgroup
{
    public int id { get; set; }
    public string name  { get; set; }
}

public class Report
{
    public int id { get; set; }
    public string name { get; set; }
    public bool isSheduled { get; set; }
}

how can i read this xml to a list of Reportgroup object using linq.
What is its syntax.
Each item in List of Reportgroup should contain list of Report

  • 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-28T00:55:54+00:00Added an answer on May 28, 2026 at 12:55 am

    Your Reportgroup class seems to be missing a way to associate with the Reports. Anyway, you can read it like this (with a few tweaks to your classes):

    public class ReportGroup // CamelCase!!!
    {
        public int Id { get; set; }
        public string Name  { get; set; }
        public List<Report> Reports { get; set; } // need to hold the associated reports
    }
    
    public class Report
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public bool IsSheduled { get; set; }
    }
    
    var doc = XDocument.Load("path/to/file.xml");
    var reportGroups = doc.Element("reportgroups")
        .Elements("Reportgroup")
        .Select(rg => new ReportGroup
        {
            Id = (int)rg.Attribute("id"),
            Name = (string)rg.Attribute("name"),
            Reports = rg.Elements("report")
                .Select(r => new Report
                {
                    Id = (int)r.Attribute("id"),
                    Name = (string)r.Attribute("name"),
                    IsScheduled = (bool)r.Attribute("isScheduled"),
                }).ToList();
        }).ToList();
    
    • 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 looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
My XML looks like this: <?xml version = 1.0 encoding = utf-8?> <gallery> <name>Rosie's
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
I am trying to parse the following XML with javascript: <?xml version='1.0' encoding='UTF-8'?> <ResultSet>
This is my xhtml code : <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC -//W3C//DTD
I have the following simplified XML: <?xml version="1.0" encoding="UTF-8" ?> <MATMAS05> <IDOC BEGIN="1"> <E1MARAM
I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8" ?> <INVOIC02> <IDOC BEGIN="1">
My Orginal XML Is <?xml version=1.0 encoding=UTF-8?> <testing> <MajorEvent> <Originator>xxxx/Originator> <Version>V1</Version> </MajorEvent> <Event Date=26-03-11_04:00:00:00
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I've an XML object converted into the following JSON object {?xml:{@version:1.0,@encoding:utf-8},Response:{Users:null,Messages:{Tell:{Notify:{@From:abc,@Message:hi system, its abc<br/>}},Group:null},PersistedMessages:{Tell:null,Group:null}}}

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.