Querying XML data by date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • labanino
    New Member
    • Aug 2006
    • 1

    #1

    Querying XML data by date

    Hello, I'm new to xml. This is what I'm trying to do! I have an html doc. with a calendar in it and a xml file attached to it with information for each day of the month. I need, for example, after clicking day 1 in the calendar, all the data for that day in my xml file to show in an external file. I don't know how to do queries and stuff like that. Any help, please!
  • bharathreddy
    New Member
    • Aug 2006
    • 116

    #2
    step: When u select a day from calendar ctl u will get the day of the month. Here I am sending only day u add the month attribute and check it with the selected month.



    Code:
    XmlTextReader xmltext =new XmlTextReader(Server.MapPath("xmlFile.xml"));
    while(xmltext.Read())
    {
      switch(xmltext.NodeType)
      {
     case XmlNodeType.Element:
        if(xmltext.Name.ToString()=="Day")
        {
          if(xmltext.GetAttribute("id").ToString()==CalenderId.Text)
           {
          txtInfoOfTheDay.Text=xmltext.ReadString();
           }
        }
        break;
       case XmlNodeType.Attribute:
          break;
       case XmlNodeType.Document:
               txtDocument.Text= xmltext.Name;
               break;
           }
    }
    
    }
    And Your Xml File would be something like this:

    Code:
    <?xml version="1.0" encoding="utf-8" ?> 
    <Calendar>
      <DayInfo>
        <Day id="1">Monday Info.......</Day>
        <Day id="2">Tuesday Info.......</Day>
        <Day id="3">Thursday Info.......</Day>
        <Day id="4">..... Info.......</Day>
        .............
        ..........
       </DayInfo>
    </Calendar>
    Last edited by Dormilich; Jan 22 '09, 09:41 AM. Reason: added [code] tags

    Comment

    Working...