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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:03:15+00:00 2026-06-14T04:03:15+00:00

I am gathering data from two different sources with the intention of populating a

  • 0

I am gathering data from two different sources with the intention of populating a single object. My class is

public class SampleClient
{
    public string ClientId { get; set; }
    public string JobName { get; set; }
    public string JobUrl { get; set; }
    public string Version { get; set; }
}

The first LINQ query populates a collection of SampleClient objects obtaining values for all except Version. I then need to loop through the collection of SampleClient and utilize ClientId value in the second query. The result of the second query is the Version value. Here is my first LINQ query:

    private void btnProjects_Click(object sender, EventArgs e)
    {
        string[] stringArray = { "demo", "sample", "test", "training" };
        List<SampleClient> jobList =
        (
            from x in XDocument.Load(XML URL VALUE HERE).Root.Elements("job")
            where x.Element("name").Value.Contains("-config") && x.Element("name").Value.StartsWith("oba-")
            && (!stringArray.Any(s => x.Element("name").Value.Contains(s)))
            select new SampleClient
            {
                ClientId = getClientId((string)x.Element("name")),
                JobName = (string)x.Element("name"),
                JobUrl = (string)x.Element("url"),
            }).ToList();

        foreach (SampleClient job in jobList)
        {
            //Display the results in a textbox
            txtResults.Text += "Job Name = " + job.JobName + " | Job URL = " + job.JobUrl + " | ";
        }
    }

In the query that obtains the version, I currently have:

var version = from item in doc.Descendants(ns + "properties")
select new SampleClient
{
    ClientId = strClientId,
    Version = (string)item.Element(ns + "product.version").Value
};

It is important to note that the URL source used in the second query is created using the ClientId that was obtained from the first. I could have a routine loop through and cleanup / merge objects, but this feels like a hack. Is there a cleaner way of handling this?

This is a sample of the XML from the first query:

<?xml version="1.0"?>
<allView>
    <description>PROD</description>
    <job>
        <name>abc</name>
        <url>http://ci-client.company.net/job/abc/</url>
        <color>blue</color>
    </job>
    <job>
        <name>acme</name>
        <url>http://ci-client.company.net/job/acme/</url>
        <color>blue</color>
    </job>
</allView>

The second query URL is dynamically created by using the clientID from the results of the first. I am using this to load in a Maven POM file and grab version information. Here is a snippet of the XML from the POM file.

<?xml version="1.0" encoding="UTF-8" ?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.company.xyz</groupId> 
    <artifactId>io</artifactId> 
    <version>6.11.7-ACME-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <properties>
        <product.version>6.11.7</product.version> 
        <db.version>1.4</db.version> 
    </properties>
    <modules>
        <module>policies</module> 
        <module>templates</module> 
        <module>assemble</module> 
    </modules>
</project>
  • 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-14T04:03:17+00:00Added an answer on June 14, 2026 at 4:03 am

    Try this:

    var jobList = from x in XDocument.Load(...
                  where ...
                  let clientId = getClientId((string)x.Element("name"))
                  select new SampleClient
                  {
                      ClientId = clientId,
                      JobName = (string)x.Element("name"),
                      JobUrl = (string)x.Element("url"),
                      Version = (string)XDocument
                          .Load(GetSecondQueryUrl(clientId))
                          .Root
                          .Element(pom4 + "properties")
                          .Element(pom4 + "product.version")
                  };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an HTML5 application that is gathering data from a few different
I am gathering data from youtube's gdata API and would like to use the
So I'm trying to automate a pretty tedious data gathering process from hundreds of
I'm developing an application for data gathering from Internet and creating charts and plots
The Story There is a writer thread, periodically gathering data from somewhere (in real-time,
I am gathering data from a website. I estimate to get 10.000 datapoints (time
I'm using a PHP array that is gathering data from a mysql database. I'm
I'm working with gathering data from a biological monitoring system. They need to know
I am trying to gather data from multiple sources on an Ubuntu 10.10 machine
My project has a requirement to gather data from a number of sources, then

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.