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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:11:47+00:00 2026-05-17T19:11:47+00:00

Ok, so I have an XML file that pretty much looks like this: <Templates>

  • 0

Ok, so I have an XML file that pretty much looks like this:

 <Templates>
    <Template>
        <TemplateID>00X500000011iTSEAY</TemplateID>
        <To>
            <To type='User'>00550000000mfOU</To>
            <To type='User'>00550000000mb3pAAA</To>
            <To type='Group'>00G50000001PiHz</To>
            <To type='AccountTeam'>AccountExecutive</To>
        </To>
        <CC>
            <CC type='AccountTeam'>SalesLead</CC>
        </CC>
        <BCC>
            <BCC type='SalesTeam'>SalesManager</BCC>
        </BCC>
    </Template>
</Templates>

With that, what I’m trying to do is to populate some classes that can make sense of that. So the first thought I had was something like this for the To Elements:

public class EmailRecipient
{
    public ToRecipient To {get;set;}
    public CCRecipient CC {get;set;}
}

public class ToRecipient
{
    public string Key {get;set;}
    public string Type {get;set;}
}

Not entirely elegant, but this is my rough draft. I’m trying to use Linq to XML for this since I know what TemplateId I have, and then I can just populate the class with the values. Here’s where I’m at…and stuck in this test app:

var results = from x in xmlDoc.Descendants(XName.Get("Template")
                      where x.Element(XName.Get("TemplateID")).Value == "00X500000011iTSEAY"
                      select new EmailRecipient()
                        {
                            ToRecipient = 
                        };

With all of that being said, I’m looking to get a collection of “Tos” where each “to” can a “type” value.

Any help would be greatly appreciated, I’ve done more in with XML in the past 3 days than have in the past 3 years, and that ain’t much.

Thanks so much for any 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-17T19:11:47+00:00Added an answer on May 17, 2026 at 7:11 pm

    Since you have more than one ToRecipient per EmailRecipient instance, the type of the To property will need to be a collection type. If you make it an IEnumerable:

        public class EmailRecipient
        {
            public IEnumerable<ToRecipient> To { get; set; }
    
        }
    

    Then this LINQ query should do the trick:

    var results = from x in xmlDoc.Descendants(XName.Get("Template"))
                  where x.Element(XName.Get("TemplateID")).Value == "00X500000011iTSEAY"
                  select new EmailRecipient()
                  {
                      To = (from to in x.Element("To").Elements("To")
                            select new ToRecipient { Key = to.Value, Type = to.Attribute("type").Value}).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
I have an XML document that is pretty much structured like an Excel spreadsheet
So I have this pretty large XML file (40MB) that I'll have to repeatedly
I have some xml that looks like this: <rootElement attribute=' > '/> This is
All, I have an XML document that looks something like this: <root> <profile> <childA>
I have an XML file that I would like to map some attributes of
I have an xml file that contains its element like <ab:test>Str</ab:test> When I am
is it possible to have app.config file like this : <?xml version=1.0 encoding=utf-8 ?>
Pretty lame problem: I have an xml file that gets updated everyday on a
I'm trying to produce an xml file that is pretty much identical to the

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.