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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:15:55+00:00 2026-06-09T10:15:55+00:00

My project idea is to create filters so that I can filter out what

  • 0

My project idea is to create filters so that I can filter out what I want the data in XML files to be appeared. I am facing the issue with datetime inconsistency. My filters are currently using TextBoxes. I was hoping to use the DateTimePicker but I have no idea how can I use it. This is my first attempt in programming and C#. Basically as long as part of the data in <item></item> tag meets the criteria (ie filters), then the whole <item></item> will be shown in my RichTextBox result area. Currently I am stuck at this point where I need to deal with the datetime format. I am totally lost.

My partial XML File:

<item>
  <title>[alfista] Max</title>
  <author>alfista</author>
  <description>Or was it just populated by non spread betters, so you found it dull and boring??  See where I am coming from?  Puffy just posted general views about direction, and I much prefer them, but then I would wouldnt I.</description>
  <link>http://www.lse.co.uk/shareChat.asp?ShareTicker=BARC&amp;post=5657481</link>
  <pubDate>Tue, 08 Aug 2012 16:08:32 GMT</pubDate>
</item>
<item>
  <title>[Maximillian] F430</title>
  <author>Maximillian</author>
  <description>Ignore the snide comments and please  keep posting in the style you have been. This board was virtually dead until you came along a few weeks ago.  </description>
  <link>http://www.lse.co.uk/shareChat.asp?ShareTicker=BARC&amp;post=5657462</link>
  <pubDate>Tue, 07 Aug 2012 16:05:04 GMT</pubDate>
</item>
<item>
  <title>[colti] divi</title>
  <author>colti</author>
  <description>Does anyone know when the divi is actually paid please</description>
  <link>http://www.lse.co.uk/shareChat.asp?ShareTicker=BARC&amp;post=5658759</link>
  <pubDate>Wed, 06 Aug 2012 06:46:25 GMT</pubDate>
</item>
<item>
  <title>[SamSri] alfista</title>
  <author>SamSri</author>
  <description>Well, sea of knowledge is out there and thus there is always something new to learn. It's better for me to be humble.</description>
  <link>http://www.lse.co.uk/shareChat.asp?ShareTicker=BARC&amp;post=5659714</link>
  <pubDate>Wed, 05 Aug 2012 08:52:35 GMT</pubDate>
</item>

My function:

private void searchComByStartDate()
{
    // Process the list of files found in the directory. 
    string[] fileEntries = Directory.GetFiles(sourceDir);
    foreach (string fileName in fileEntries)
    {
        XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.

        string docPath = fileName;

        xmlDoc.Load(docPath); //* load the XML document from the specified file.

        XmlNodeList nodeList = xmlDoc.GetElementsByTagName("item");

        foreach (XmlNode node in nodeList)
        {

            XmlElement itemElement = (XmlElement)node;

            string itemDate = itemElement.GetElementsByTagName("pubDate")[0].InnerText;

            if (itemDate >= txtComStartDate)
            {
                string itemAuthor = itemElement.GetElementsByTagName("author")[0].InnerText;
                string itemTitle = itemElement.GetElementsByTagName("title")[0].InnerText;
                string itemDescription = itemElement.GetElementsByTagName("description")[0].InnerText;

                richComResults.AppendText("Author: " + itemAuthor + "\nDate: " + itemDate + "\nTitle: " + itemTitle + "\nDescription: " + itemDescription + "\n\n--------\n\n");
            }
        }
    }
}

In this line if (itemDate >= txtComStartDate), it is obviously very wrong because it says “Operator >= cannot be applied to string and textbox”. I know LINQ to XML can make my life easier, but if I want to stick with XmlDocument, can somebody please fix my current problem? Because I am very new to programming, I just learnt very little thing about parsing XML files.

I have two filters in my C# winforms which are txtComStartDate and txtComEndDate. Users can either input txtComStartDate or txtComEndDate or both.

Case 1: if txtComStartDate – 06/08/12, then the result will show in my richComResults only the <item></item> that start from 06/08/12 to the latest.


Case 2: if txtComEndDate – 07/08/12, then the result will show in my richComResults only the <item></item> that appear before 07/08/12.


Case 3: if txtComStartDate – 06/08/12 & txtComEndDate – 07/08/12, then the result will show in my richComResults only the <item></item> occurred within these two dates.

  • 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-09T10:15:57+00:00Added an answer on June 9, 2026 at 10:15 am

    You need to parse the date string in both xml and textbox value. Looks like your xml dates are in the RFC 1123 format so DateTime.Parse(itemDate) should work.
    As for the textbox, this depends on the user and you can’t know for sure what is the format he uses. You can instruct him to enter dates in “dd/MM/yy” (this is what you used) and parse the date with DateTime.ParseExact.

    using System.Globalization;
    
    CultureInfo provider = CultureInfo.InvariantCulture;
    if (DateTime.Parse(itemDate) >= DateTime.ParseExact(txtComStartDate.Text, "dd/MM/yy", provider))
    

    I recommend you try to use a DateTimePicker. For more reading about DateTime format strings look here:
    http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

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

Sidebar

Related Questions

Can somebody tell me how can I create an Seam project for Intellij IDEA?
I can't find how to create PHP project with IntelliJ Idea 9. It only
I am trying to create an OSGI project on IntelliJ Idea but so far
When creating a new Java project in IntelliJ IDEA, the following directories and files
I was trying to debug a GWT project in intelliJ IDEA 11. I can
I have a Visual Studio Installation Project and I want the Installer to create
I'm working in a big project.I'm thinking of a new idea to create the
If sbt-idea is used to create a sbt based intelliJ project, then what is
I understand that the idea is to create basic HTTP Requests using GET or
As a project I would like to create a website that allows a user

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.