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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:24:23+00:00 2026-05-23T23:24:23+00:00

I have 3 XML files I can join by id. var test = from

  • 0

I have 3 XML files I can join by id.

 var test = from b in doc.Descendants("CalendarFair")
                        let start = b.Element("DateStart").Value
                        where 
                          start.Substring(0, 2) == dateNow.Substring(0, 2) &&
                          start.Substring(6, 4) == dateNow.Substring(6, 4)
                        let id1 = b.Element("IdExecutive").Value
                        join c in doc1.Descendants("Executive")
                        on id1 equals c.Element("Id").Value

                        select new
                        {
                            Title = b.Element("Title").Value,
                            DateStart=b.Element("DateStart").Value,
                            DateEnd=b.Element("DateEnd").Value, 
                            NameExecutive = c.Element("NameExecutive").Value,

                        };

this code join CalendarFair and Executive now how can join FairCenter to this code

 var test = from b in doc.Descendants("CalendarFair")
                        let start = b.Element("DateStart").Value
                        where start.Substring(0, 2) == dateNow.Substring(0, 2) &&
                            start.Substring(6, 4) == dateNow.Substring(6, 4)
                        let id1 = b.Element("IdExecutive").Value
                        join c in doc1.Descendants("Executive")
                        on id1 equals c.Element("Id").Value
                        join d in doc3.Descendants("FairCenter")
                        on ........ //by id
                        select new
                        {
                            Title = b.Element("Title").Value,
                            DateStart=b.Element("DateStart").Value,
                            DateEnd=b.Element("DateEnd").Value, 
                            NameExecutive = c.Element("NameExecutive").Value,
                            telExecutive = c.Element("Tel").Value,
                            websiteExecutive = c.Element("Website").Value

                        };

FairCenter.xml

<FairCenters>
   <FairCenter>
      <Name>c1</Name>
      <Id>1</Id>
   </FairCenter>
  <FairCenter>
      <Name>c2</Name>
      <Id>1</Id>
   </FairCenter>


Executives.xml

<Executives>
   <Executive>
      <NameExecutive>e1</NameExecutive>
      <Id>1</Id>
  </Executive>
   <Executive>
      <NameExecutive>e2</NameExecutive>
      <Id>2</Id>
  </Executive>
</Executives>

CalendarFair.xml

<CalendarFairs>
  <CalendarFair>
     <DateStart>09/09/2011</DateStart>
     <DateEnd>07/15/2011</DateEnd>
     <Title>f1</Title>
     <IdExecutive>1</IdExecutive>
     <IdCenter>1</IdCenter>
  </CalendarFair>
  <CalendarFair>
      <DateStart>07/14/2011</DateStart>
      <DateEnd>07/20/2011</DateEnd>
      <Title>f2</Title>
      <IdExecutive>5</IdExecutive>
      <IdCenter>2</IdCenter>
  </CalendarFair>
</CalendarFairs>

Answer

 var test = from b in doc.Descendants("CalendarFair")
                        let start = b.Element("DateStart").Value
                        where start.Substring(0, 2) == dateNow.Substring(0, 2) && start.Substring(6, 4) == dateNow.Substring(6, 4)
                        let id1 = b.Element("IdExecutive").Value
                        let id2 = b.Element("IdCenter").Value 
                        join c in doc1.Descendants("Executive")
                        on id1 equals c.Element("Id").Value
                        join d in doc3.Descendants("FairCenter")
                        on id2 equals d.Element("Id").Value
                        select new
                        {
                            Title = b.Element("Title").Value ,
                            DateStart=b.Element("DateStart").Value,
                            DateEnd=b.Element("DateEnd").Value, 
                              NameExecutive = c.Element("NameExecutive").Value,
                            telExecutive = c.Element("Tel").Value,
                            websiteExecutive = c.Element("Website").Value,
                            NameCenter = d.Element("Name").Value
                        };
  • 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-23T23:24:23+00:00Added an answer on May 23, 2026 at 11:24 pm

    It looks to me like you just need:

     join d in doc3.Descendants("FairCenter")
     on b.Element("IdFair").Value equals d.Element("Id").Value
    

    What was giving you problems with that? Note that you don’t really need all those let statements for the joins. I think it would be clearer as:

    var test = from b in doc.Descendants("CalendarFair")
               where ...
               join c in doc1.Descendants("Executive")
                 on b.Element("IdExecutive").Value equals c.Element("Id").Value
               join d in doc3.Descendants("FairCenter")
                 on b.Element("IdFair").Value equals d.Element("Id").Value  
    

    That makes it really clear which elements you’re matching at each stage.

    I assume you’ll want to use d in your projection, too…

    (You should probably look at casting DateStart to a DateTime rather than using all those substring operations, by the way.)

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

Sidebar

Related Questions

I have a T4 template that generates classes from an xml file. How can
I need to find a way to join two XML files when they have
In My iphone application i have two XML files. I can parse one.xml eailsy
Do the XSD (XML schema) files have usually extension .xsd or they can have
I have created XML file,but I can't view it/output it.I know there is no
I have a custom XML file format which can contain blocks of code within
I have a .xml file in my App_Data folder, I can access it fine
What are DataContracts in WCF ? I have an XML file , how can
How can I have a text file (or XML file) represented as a whole
I have to encrypt/decrypt some sensitive information in a Xml file? Yes I can

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.