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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:07:27+00:00 2026-05-25T17:07:27+00:00

I have code that extracts data out of an XML file. I want to

  • 0

I have code that extracts data out of an XML file. I want to find the average / mean value for each of the extracted values (XMax, XMin, YMax, YMin, ZMax, ZMin)

Here is how I extracted the six values:

var query = from file in fileEntries
            let doc = XDocument.Load(file) 
            let x = doc.Descendants("XAxisCalib").Single() 
            let y = doc.Descendants("YAxisCalib").Single() 
            let z = doc.Descendants("ZAxisCalib").Single() 
            select new
            {
                XMax = x.Element("Max").Value, 
                XMin = x.Element("Min").Value, 
                YMax = y.Element("Max").Value, 
                YMin = y.Element("Min").Value, 
                ZMax = z.Element("Max").Value, 
                ZMin = z.Element("Min").Value 
            };

Am I on the right track with this average for XMax:

 var Average1 =
    from a in query
    select new 
    { AvgMaxX =  a.Average(a => a.XMax) };
  • 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-25T17:07:27+00:00Added an answer on May 25, 2026 at 5:07 pm
    var averageMaximumX = query.Average(t => t.XMax);
    var averageMinimumX = query.Average(t => t.XMin);
    var averageMaximumY = query.Average(t => t.YMax);
    var averageMinimumY = query.Average(t => t.YMin);
    var averageMaximumZ = query.Average(t => t.ZMax);
    var averageMinimumZ = query.Average(t => t.ZMin);
    

    EDIT: To convert the strings to doubles or decimals or whatever:

    var averageMaximumX = query.Average(t => double.Parse(t.XMax));
    //OR: var averageMaximumX = query.Average(t => decimal.Parse(t.XMax));
    

    But I would actually do it in the select:

    select new
    {
        XMax = double.Parse(x.Element("Max").Value),
        XMin = double.Parse(x.Element("Min").Value),
    // etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML file that has the following data, <extcode Type=abc Code=12345 />
I have an application that extracts data from some xml that is stored in
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);
I have code that I want to look like this: List<Type> Os; ... foreach
I have code that I want to compile on all unix systems, but if
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
is that possible to extract out all the data in second sheet from each
Currently, I have the following c# code to extract a value out of text.
I have the following code that I am trying to extract the systems proxy
I have code that references a web service, and I'd like the address of

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.