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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:05:53+00:00 2026-05-14T14:05:53+00:00

i am using a large xml file having in the following format: <Sales> <Sale>

  • 0

i am using a large xml file having in the following format:

<Sales>
  <Sale>
    <Date>04/20/2010</Date>
    <Time>18:17:29</Time>
    <Id>P00000001</Id>
    <Name>Prod Name</Name>
    <Description>Prod Desc</Description>
    <Category>Prod Category</Category>
    <Subcategory>Prod Subcategory</Subcategory>
    <Size>Prod Size</Size>
    <Price>25</Price>
    <Image>image path</Image>
  </Sale>
<Sales>

my goal is to display to sum the prices and count items sold for a period of time:

    XDocument xmlDoc = XDocument.Load("Data.xml");

        DateTime date = new DateTime();
        var queryWeek = from sale in xmlDoc.Descendants("Sale")
                        where ((sale.Element("Date")>= date.Date.AddDays(-7)) && ((sale.Element("Date")<= date.Date())))
                        select sale.Element("Price");

       Console.WriteLine("",queryWeek);

debugger complains:
Error 1 Operator ‘>=’ cannot be applied to operands of type

'System.Xml.Linq.XElement' and 'System.DateTime'

Error 2 Non-invocable member 'System.DateTime.Date' cannot be used like a method. 

help please
devin

  • 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-14T14:05:54+00:00Added an answer on May 14, 2026 at 2:05 pm

    You are attempting to compare a DateTime and the XElement. You need to change the XElement to a DateTime for comparison: DateTime.Parse(sale.Element("Date").Value) >= date.Date.AddDays(-7).

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

Sidebar

Related Questions

I'm using following code to parse rather large xml file (> 50GB): use XML::Parser;
I'm having a bit of an issue. I'm parsing a large xml file using
I am using XMLReader to read a large XML file with about 1 million
I'm looking for solution to extract some node from large xml file (using xmlstarlet
I'm reading a large xml file using HttpURLConnection in java as follows. StringBuilder responseBuilder
I'm using XDocument and XElement objects to write a large XML file (currently 8MB).
What is the cost of parsing a large XML file using PHP on every
I am getting information from a large xml file and I am using python
I'm trying to parse a moderately large XML file (6mb) in php using simpleXML.
I am using InputSource to parse a large xml file (1.2 mb). I need

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.