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!
Querying XML data by date
Collapse
X
-
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.
And Your Xml File would be something like this: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; } } }
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>
Comment