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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:50:04+00:00 2026-06-14T07:50:04+00:00

How we can read in a list the values from the target P (Price)

  • 0

How we can read in a list the values from the target P (Price) from the following xml?

<D d="2012-11-01">
  <P t="00:00:00+01:00">39.90999985</P> 
  <P t="01:00:00+01:00">36.22999954</P> 
  <P t="02:00:00+01:00">29.44000053</P> 
</D>
<D d="2012-11-02">
  <P t="00:00:00+01:00">32.33000183</P> 
  <P t="01:00:00+01:00">29.12999916</P> 
  <P t="02:00:00+01:00">30.18000031</P> 
  <P t="03:00:00+01:00">29.12999916</P> 
</D>

I know the procedure (there are other topics here for this) in C# but i have the query of the chances inside the target P and D. Play this any role or if i read from target P it will read all the prices like the above xml file

 <D>
  <P>39.90999985</P> 
  <P>36.22999954</P> 
  <P>29.44000053</P> 
</D>
  • 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-14T07:50:05+00:00Added an answer on June 14, 2026 at 7:50 am
    class Price
    {
        public DateTime? Timestamp { get; set; }
        public decimal Price { get; set; }
    }
    
    public IEnumerable<Price> GetPrices(XDocument document)
    {
        return
            from d in document.Root.Elements("D")
            let date = d.Attribute("d")
            from p in d.Elements("P")
            let time = p.Attribute("t")
            select new Price
            {
                Timestamp = (date == null || time == null)
                    ? (DateTime?) null
                    : DateTime.Parse(date.Value + " " + time.Value),
                Price = Convert.ToDecimal(p.Value)
            };
    }
    

    Alternatively, using XmlSerializer (Assuming the root-element is named <Data>):

    [XmlType]
    public class Data : List<Day>
    {   
    }
    
    [XmlType("D")]
    public class Day
    {
        [XmlAttribute("d")]
        public string Date { get; set; }
    
        [XmlElement("P")]
        public List<Price> Prices { get; set; }
    }
    
    public class Price
    {
        [XmlAttribute("t")]
        public string Time { get; set; }
    
        [XmlText]
        public decimal Value { get; set; }
    }
    
    public Data ParseXml(TextReader reader)
    {
        var ser = new XmlSerializer(typeof(Data));
        return (Data) ser.Deserialize(reader)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can Read the RGB-Pixel by Pixel values from CGImagea also after how
I created a thread. How can I read values of variables from GUI thread?
How can i use opendir function to read the directory list of a remote
I need to perform some operations on a 2D array of values read from
I know you can read a gui control from a worker thread without using
I like to ask, how I can read data from my databast test_database.db and
This loads a set of values from an XML file and places them into
In my application I read RGB pixel values from several images using fast unmanaged
I have a dictionary of values read from two fields in a database: a
I was wondering how can I find minimum and maximum values from a dataset,

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.