473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Calendar notes in .xml

Hi, I am making a simple calendar. I would like to have the ability of
notes. I was thinking of using this kind of notes.xml file. I am not
sure how to operate with nodes. I just need to access something like
SelectNode("/NOTES/y"+Year+"/m"+Month+"/d"+Day); (I'd get
/NOTES/y2006/m5/d18) and than I'd read what is in there. Can anyone
help please?
<NOTES>
<y2006>
<m4>
<DAYS>1,2,13</DAYS>
<DESCRIPTION>
<d1>New Year</d1>
<d2>Day after New Year</d2>
<d13>Special day :)</d13>
</DESCRIPTION>
</m4>
<m5>
<DAYS>1,30</DAYS>
<DESCRIPTION>
<d1>New Year</d1>
<d30>Special day :)</d30>
</DESCRIPTION>
</m5>
</y2006>
<y2007>
<m2>
<DAYS>5,28</DAYS>
<DESCRIPTION>
<d5>Service</d5>
<d28>Change tyers.</d28>
</DESCRIPTION>
</m2>
</y2007>
</NOTES>

Jul 29 '06 #1
9 2020
bo********@gmail.com wrote:
Hi, I am making a simple calendar. I would like to have the ability of
notes. I was thinking of using this kind of notes.xml file. I am not
sure how to operate with nodes. I just need to access something like
SelectNode("/NOTES/y"+Year+"/m"+Month+"/d"+Day); (I'd get
/NOTES/y2006/m5/d18) and than I'd read what is in there. Can anyone
help please?
Have a look at the XmlDocument class. It provides the two methods called
SelectSingleNode and SelectNodes that you can pass your XPath expression
to. Does that help?
<NOTES>
<y2006>
<m4>
Instead of naming your elements like that, maybe it would be nicer to
use attributes? Like:

<Notes>
<Note Year="2006" Month="4" Day="1">New Year</Note>
<Note Year="2006" Month="4" Day="2">Day after New Year</Note>
<Note Year="2006" Month="4" Day="13">Special day :)</Note>
</Notes>

... you can query that with XPath too:
/Notes/Note[Year="2006" and Month="4" and Day="13"]

hth,
Max
Jul 29 '06 #2
Markus Stoeger wrote:
/Notes/Note[Year="2006" and Month="4" and Day="13"]
that should have been:
/Notes/Note[@Year="2006" and @Month="4" and @Day="13"]

Max
Jul 29 '06 #3
Hi could someone provide more information and perhaps an example.
Thank you guys

Jul 30 '06 #4
bo********@gmail.com wrote:
Hi could someone provide more information and perhaps an example.
Thank you guys
Have you read the MSDN docs for the methods I mentioned? They provide
lots of information and examples.

Max
Jul 30 '06 #5
Hi, yes I have but I am not sure.

My code looks like:
//Start code
XmlDocument doc = new XmlDocument();
doc.Load("notes.xml");

XmlNodeList nodeList;
XmlNode root = doc.DocumentElement;

nodeList=root.SelectNodes("/Notes/note[@Year="+this.Year.ToString()+"]");

//Save notes to a. A will be displayed later.
foreach (XmlNode note in nodeList)
{
a=note.InnerText.ToString();
}
//End code

And it does not works. The XML looks like you suggested. I am not sure
about XPath. I think it is not correct. Could you tell me some more
info about this?

Thank you,
Bojan

Aug 1 '06 #6
bo********@gmail.com wrote:
Hi, yes I have but I am not sure.

My code looks like:
nodeList=root.SelectNodes("/Notes/note[@Year="+this.Year.ToString()+"]");
XPath is case sensitive. Are you sure your Xml element is called "note"
and not "Note"? Makes a difference! Otherwise it looks good.
//Save notes to a. A will be displayed later.
foreach (XmlNode note in nodeList)
{
a=note.InnerText.ToString();
What is 'a'? Are you sure you don't need '+=' instead of '='?
And it does not works. The XML looks like you suggested. I am not sure
about XPath. I think it is not correct. Could you tell me some more
info about this?
Here is a short introduction to xpath that explains everything one has
to know about about it: http://www.w3schools.com/xpath/xpath_intro.asp

hth,
Max
Aug 1 '06 #7
Hi Markus,

it now works. Thank you for helping me.

Now I have to make a method that will insetred new notes into XML
database.
Could you tell me some methods for this?

Thanks again,
Bojan

Aug 4 '06 #8
I found an example:

XmlNode root = doc.DocumentElement;
XmlElement elem = doc.CreateElement("note");
elem.InnerText="Visit doctor at 5 PM";
root.InsertAfter(elem, root.FirstChild);

But I dont know how to setup a parametrs (Year, Month, Day).

Aug 4 '06 #9
bo********@gmail.com wrote:
I found an example:

XmlNode root = doc.DocumentElement;
XmlElement elem = doc.CreateElement("note");
elem.InnerText="Visit doctor at 5 PM";
root.InsertAfter(elem, root.FirstChild);

But I dont know how to setup a parametrs (Year, Month, Day).
These values are called xml attributes. Have a look at the documentation
of the method XmlElement.SetAttribute(string name, string value):

elem.SetAttribute("Year", "2006");

There's also GetAttribute to read the value back.

hth,
Max
Aug 4 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
1
by: John | last post by:
Hello, Is there a way, preferably an example, to export a couple of people's outlook calendars to a web based calendar? We want to be able to allow each person to import their calendar so the...
0
by: Luis Esteban Valencia | last post by:
Hi folks, I have a problem using the Calendar Control. Let me explain: On my first page, "Default.aspx", I have a calendar control named "calPrimary". I then have a Web User Control on the...
1
by: Max | last post by:
Hi , I need to build a report (or form) with a calendar that will show some infos from a table that has a date field. I want to show on the calendar the info depending of this date field. ...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
1
by: sandeeprmenon | last post by:
Combining bit & peices from different discussion forums, I created this program (see below) to send meeting invitation from Lotus Notes using VBA. Program successfully sends the invitation to all...
1
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I...
1
by: KDawg44 | last post by:
Hi, We have a Lotus Notes Database that tracks time spent on projects. What I would like to do is develop a Time Tracker in Python that communicates with the server. This would pull projects in...
30
by: Jo at Isla | last post by:
I am away from UK travelling - hence no access to my VB software and previous build notes etc but have said that i will build a simple reservation system for the people with whom i am staying. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.