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

  • Home
  • SEARCH
  • 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 7814319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:09:35+00:00 2026-06-02T05:09:35+00:00

I have a complicated case: I have three XML files, which I need to

  • 0

I have a complicated case: I have three XML files, which I need to read simultaneously and get the results based on matches. Below is a working (but fake) example, almost similar to what I am doing.

For instance, I have two xml file, both are similar but in terms of tags and attributes, but with different contents (languages). I’m reading both languages at the same time, like in the code in a C# file:

XElement x1 = XElement.Load (@"abc.xml");
XElement x2 = XElement.Load (@"xyz.xml");


var ch = from var1 in x1.Elements("language1") 
         where var1.Attribute("index").Value == "1"
         from var2 in x2.Elements("language2")
         where var2.Attribute("index").Value == var1.Attribute("index").Value
         select dictChapter as new
         {  
             sentenceNumber = var1.Attribute("index").Value,
             SentenceInLanguage1 = var1.Attribute("text").Value,
             SentenceInLanguage2 = var2.Attribute("text").Value,
         };

ListBox.DataContext = ch;

The problem here is that, x1 contains 1000 sentences and so x2. The above logic work like a nested loop, which is slowing down the processing a lot. It works like

x1.1 -> x2.1:1000
x1.2 -> x2.1:1000

or

for i in x1
  for j in x2

Is there any better and efficient way to select the sentences from x1 and x2,where the sentence id of x1 is equal to the sentence id of x2?

  • 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-06-02T05:09:38+00:00Added an answer on June 2, 2026 at 5:09 am

    From what I understood that you want,

    You could use join to do that.

    Here is a good example link LINQ to XML : Join Xml Data (Wriju’s BLOG)

    …or something along these lines…

    var root = (from var1 in x1.Elements("language1")
                join var2 in x2.Elements("language2") on (string)var1.Attribute("index") equals (string)var2.Attribute("index")
                select new
                {
                    SentenceNumber = (string)var1.Attribute("index"),
                    SentenceInLanguage1 = (string)var1.Element("text"),
                    SentenceInLanguage2 = (string)var2.Element("text")
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complicated problem, and I need help. I have a base case,
I have a complicated MySQL query which takes a lot of time, selecting from
I have a complicated report that I need to draw with GDI+ (I don't
I have some complicated, problem to be solved. Now I need to write such
I need to perform a complicated calculation. In my case it seemed most natural
I have a complicated problem and I hope to explain it clearly possible... I
I have this complicated slider that utilizes tons of animation. I'm trying to find
I have a complicated nested form (Ryan Bates' version) with .live() attached to some
I've got a program where a lot of classes have really complicated configuration requirements.
Im having a very strange problem, i have a complicated view that returns incorrect

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.