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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:34:18+00:00 2026-05-15T07:34:18+00:00

I have the following XML: <PerformancePanel page=PerformancePanel.ascx title=> <FundGroup heading=Net Life Managed Funds> <fund

  • 0

I have the following XML:

  <PerformancePanel page="PerformancePanel.ascx" title="">
    <FundGroup heading="Net Life Managed Funds">
      <fund id="17" countryid="N0" index="24103723" />
      <fund id="81" countryid="N0" index="24103723" /> 
      <fund id="127" countryid="N0" index="24103722" />
      <fund id="345" countryid="N0" index="24103723" />
      <fund id="346" countryid="N0" index="24103723" />
    </FundGroup>
    <FundGroup heading="Net Life Specialist Funds">
      <fund id="110" countryid="N0" index="24103717" />
      <fund id="150" countryid="N0" index="24103719" />
      <fund id="119" countryid="N0" index="24103720" />
      <fund id="115" countryid="N0" index="24103727" />
      <fund id="141" countryid="N0" index="24103711" />
      <fund id="137" countryid="N0" />
      <fund id="146" countryid="N0" />
      <fund id="133" countryid="N0" />
      <fund id="90" countryid="N0"  />
      <fund id="104" countryid="N0" />
      <fund id="96" countryid="N0" />
    </FundGroup>
  </PerformancePanel>

I can get the data into an anonymous object as follows:

    var offlineFactsheet = new
                               {
   PerformancePanels =
    (from panel in doc.Elements("PerformancePanel")
     select new PerformancePanel
     {
         PerformanceFunds = (from fg in panel.Elements("FundGroup")
                             select new
                             {
                                 Heading = (fg.Attribute("heading") == null)
                                            ? ""
                                            : (string)fg.Attribute("heading"),
                                 Funds =
                                    (from fund in fg.Elements("fund")
                                     select new Fund
                                     {
                                         FundId = (int)fund.Attribute("id"),
                                         CountryId = (string)fund.Attribute("countryid"),
                                         FundIndex = (fund.Attribute("index") == null)
                                                 ? null
                                                 : new Index
                                                 {
                                                     Id = (int)fund.Attribute("index")
                                                 },
                                         FundNameAppend = (fund.Attribute("append") == null)
                                                 ? ""
                                                 : (string)fund.Attribute("append")
                                     }).ToList()
                             }).ToDictionary(xx => xx.Heading, xx => xx.Funds)};

I’m trying to change my code such that I can assign the dictionary directly to a property of the class I’m working in, as described in this question.
I’d like to have a Dictionary() where each header text is the key to the list of funds under it. I’m having difficulty applying the example in the linked question because that only returns a string, and this needs to return the dictionary.

This is the point that I got to before it occurred to me that I’m lost!!!:

this.PerformancePanels = doc.Elements("PerformancePanel").Select(e =>
 {
     var control = (PerformancePanel)LoadControl(this.OfflineFactsheetPath
                                                + (string)e.Attribute("page"));

     control.PerformanceFunds = e.Elements("FundGroup").Select(f =>
     {
         List<Fund> funds = (from fund in e.Elements("fund")
                             select new Fund
                                        {
                                            FundId = (int)fund.Attribute("id"),
                                            CountryId = (string)fund.Attribute("countryid"),
                                            FundIndex = (fund.Attribute("index") == null)
                                                            ? null
                                                            : new Index
                                                                  {
                                                                      Id = (int)fund.Attribute("index")
                                                                  },
                                            FundNameAppend = (fund.Attribute("append") == null)
                                                                 ? ""
                                                                 : (string)fund.Attribute("append")
                                        }).ToList();
         string heading = (e.Attribute("heading") == null)
                              ? ""
                              : (string)e.Attribute("heading");
     }).ToDictionary(xx => heading, xx => Funds);
     return control;
 }).ToList();

Could someone point me in the right direction please? I’m not even sure if ‘Expression’ is the right terminology. Could someone fill me in on that too? 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-05-15T07:34:19+00:00Added an answer on May 15, 2026 at 7:34 am

    I figured it out:

    this.PerformancePanels = doc.Elements("PerformancePanel").Select(e =>
     {
         var control = (PerformancePanel)LoadControl(this.OfflineFactsheetPath
                                                    + (string)e.Attribute("page"));
    
    
    
         control.PerformanceFunds = e.Elements("FundGroup").ToDictionary(xx => (string)xx.Attribute("heading"),
                                                                         xx => xx.Elements("fund").Select(g =>
              {
                  Fund fund = new Fund
                                  {
                                      FundId = (int)g.Attribute("id"),
                                      CountryId = (string)g.Attribute("countryid"),
                                      FundIndex = (g.Attribute("index") == null)
                                      ? null : new Index
                                                   {
                                                       Id = (int)g.Attribute("index")
                                                   },
                                      FundNameAppend = (g.Attribute("append") == null)
                                         ? ""
                                         : (string)g.Attribute("append")
                                  };
                  return fund;
              }).ToList());
    
         return control;
     }).ToList();
    

    It turns out I didn’t need to do the select(), just the ToDictionary() method, with the parameters being filled by the ‘expressions’.. (if that’s the right word?!)

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

Sidebar

Related Questions

i have the following xml <?xml version=1.0 encoding=ISO-8859-1 ?> <bookstore> <book category=cooking> <title lang=en>Everyday
I have the following xml file in my res/raw folder - Title of RSS
I have the following XML file: <phonebook> <departments> <department id=1 parent= title=Rabit Hole address=
Let's assume I have following XML: <element1 title=title1> <element2 title=title2> <element3 title=title1> Here attribute
I have following xml and I want to fetch the value of node which
I have following XML, and i wish to save its data in my SQL
I have following XML. I was able to remove all namespaces but not able
I have following xml file: <ab> <![CDATA[ <table> <tbody> <tr> <th>abcdef</th> </tr> <tr> <p>
I have following xml as a response to a service not i want to
Currently I have following XML: <Rowsets> <Rowset> <Row> <DrilldownDepth>0</DrilldownDepth> <ScheduleWeek>---</ScheduleWeek> <ABC>---</ABC> <PQR>1500</PQR> <XYZ>15000</XYZ> <Quant>285</Quant>

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.