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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:41:28+00:00 2026-05-27T10:41:28+00:00

SOLVED – Thanks for your help everyone! Before I get to my code, I’d

  • 0

SOLVED – Thanks for your help everyone!

Before I get to my code, I’d like to offer a short explanation of what it is I’m trying to accomplish. I have an XML file in the Data folder, which has 3 Elements per descendant: Month, High and Low. Each descendant is already in the appropriate order based on Month, but I need to convert the high and low strings to doubles, so that I can use them to plot points on a graph. That is the part I am unable to accomplish.

What I have so far:

    double month = 25;
    const double temp = 275;

    string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\";
    XDocument xmlSource;

    private void btnShowAlbany_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            //Brush, Polyline, PointCollection for drawing
            SolidColorBrush myBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
            Polyline myLine = new Polyline();
            myLine.Stroke = myBrush;
            myLine.StrokeThickness = 2;
            PointCollection myPoints = new PointCollection();

            double theTemp = 0;

            //Get XML data
            xmlSource = XDocument.Load(path + @"\Albany.xml");
            var myTemps = from tmp in xmlSource.Descendants("temp")
                            select new
                            {
                                Month = tmp.Element("Month").Value,
                                High = tmp.Element("High").Value,
                                Low = tmp.Element("Low").Value
                            };

            //Pull out data for points
            foreach (var x in myTemps)
            {
                double high = Convert.ToDouble(x.High);
                double low = Convert.ToDouble(x.Low);
                theTemp = (high + low) / 2;

                myPoints.Add(new Point(month, temp - theTemp));
                month += 25;
            }

            //Add points to line, add line as child of canvas
            myLine.Points = myPoints;
            albanyCanvas.Children.Add(myLine);
        }
        catch
        {
            MessageBox.Show("Error accessing data source", "Show Temps", MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }

Any guidance is appreciated, thanks.

(Note: My canvas grid values begin at 25 X, 275 Y, eg. a temp of 25 in Feb would be plotted @ 50,250)

The XML file:

<?xml version="1.0" encoding="utf-8"?>
<Temps>
  <Temp>
    <Month>Jan</Month>
    <High>31</High>
    <Low>15</Low>
  </Temp>
  <Temp>
    <Month>Feb</Month>
    <High>35</High>
    <Low>17</Low>
  </Temp>
  <Temp>
    <Month>Mar</Month>
    <High>44</High>
    <Low>26</Low>
  </Temp>
  <Temp>
    <Month>Apr</Month>
    <High>58</High>
    <Low>37</Low>
  </Temp>
  <Temp>
    <Month>May</Month>
    <High>69</High>
    <Low>47</Low>
  </Temp>
  <Temp>
    <Month>Jun</Month>
    <High>78</High>
    <Low>57</Low>
  </Temp>
  <Temp>
    <Month>Jul</Month>
    <High>82</High>
    <Low>62</Low>
  </Temp>
  <Temp>
    <Month>Aug</Month>
    <High>80</High>
    <Low>60</Low>
  </Temp>
  <Temp>
    <Month>Sep</Month>
    <High>72</High>
    <Low>52</Low>
  </Temp>
  <Temp>
    <Month>Oct</Month>
    <High>60</High>
    <Low>40</Low>
  </Temp>
  <Temp>
    <Month>Nov</Month>
    <High>48</High>
    <Low>32</Low>
  </Temp>
  <Temp>
    <Month>Dec</Month>
    <High>36</High>
    <Low>21</Low>
  </Temp>
</Temps>
  • 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-27T10:41:29+00:00Added an answer on May 27, 2026 at 10:41 am

    XML is case sensitive. Fix your selector to be .Descendants("Temp")

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

Sidebar

Related Questions

SOLVED!!!! Thanks for your help I'm kinda lost here, I'd like to remove all
SOLVED MY OWN QUESTION! THANKS EVERYONE FOR THE HELP :) Ok. I'm having trouble
Solved Problem: to show external code dependency by submodules: Thanks to VonC ! Current
Solved My code was never before used for processing signed values and as such
SOLVED: View the answer below marked SOLVED. Thanks. I am trying to download a
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
SOLVED I misspelled the property department -> Department. Thanks for the answers and a
Update: Solved, with code I got it working, see my answer below for the
SOLVED: See my solution below! using aspx with C# code behind. I have the
SOLVED: Error in template file I have Smarty setup like this: require_once 'smarty/Smarty.class.php'; $smarty

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.