Je voudrais réaliser un calendrier en XMLRAD en m'aidant de Delphi mais je dois dire avoir un petit probleme au niveau de la boucle, car je voudrais créer un noeud sur mon fichier XML CellS qui a en fils Cell qui se créer pour chaque nouvelle semaine et encore en fils un noeuds Week qui se créer pour chaque jour du mois, mais mon probleme est qu'il me m'est en fil a chaque fois le noeuds Week alors que je voudrais le voir en fil mais du noeuds Cell, voici un exemple de ce que je vois et une exemple ensuite de ce que je voudrais voir :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
Cells 
  Cell 
   Week 
     . 
     . 
     . 
   /Week 
  Cell 
   Week 
     . 
     . 
     . 
   /Week

Et ce que je vois en XML :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
Cells 
  Cell 
   Week 
     Week 
        Week 
         . 
         . 
         . 
        /Week 
     /Week 
  /Week

Voici mon code Delphi pour ceux qui pourrais me trouver cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
var Params: IXMLCursor; 
    cDate, Date, result:string; 
    BDate: TDateTime; 
    NBdays, Days: array[1..7] of string; 
    DateNow :TDateTime; 
    Year, Month, Day: Word; 
    Jour, i, Week: Integer; 
begin 
  Date := DateToStr(Now); 
  DateTimeToString(cDate,'dd mmmm yyyy',Now); 
  Params:=OutputDoc.Select('/document'); 
  Params:=Params.AppendChild('Date',''); 
  Params.AppendChild('Date',(cDate)); 
  begin 
    Days[1] := '1';   //Sunday 
    Days[2] := '2';   //Monday 
    Days[3] := '3';   //Tuesday 
    Days[4] := '4';   //Wednesday 
    Days[5] := '5';   //Thursday 
    Days[6] := '6';   //Friday 
    Days[7] := '7';   //Saturday 
    BDate := StrToDate(Date); 
    Params.AppendChild ('DayOfWeek',Days[DayOfWeek(BDate)]); 
    begin 
      DateNow:= Now; 
      DecodeDate(DateNow, Year, Month, Day); 
      Params.AppendChild ('Day',IntToStr(Day)); 
      Params.AppendChild ('Month',IntToStr(Month)); 
      Params.AppendChild ('Year',IntToStr(Year)); 
    end; 
    begin 
      i:= DayOfWeek (BDate); 
      Jour := 1; 
      while Jour < Day do 
        begin 
          i := i; 
          i := i - 1; 
          Jour := Jour + 1 
        end; 
      Params:=OutputDoc.Select('/document'); 
      Params:=Params.AppendChild('CellS',''); 
      Params:=Params.AppendChild('Cell',''); 
      result:= ''; 
      i:= DayOfWeek (i); 
      Jour := 1; 
      Week := 1; 
      Month := 1; 
      Nbdays[1] := 'Sunday'; 
      Nbdays[2] := 'Monday'; 
      Nbdays[3] := 'Tuesday'; 
      Nbdays[4] := 'Wednesday'; 
      Nbdays[5] := 'Thursday'; 
      Nbdays[6] := 'Friday'; 
      Nbdays[7] := 'Saturday'; 
      Params:=OutputDoc.Select('/document/CellS/Cell'); 
      While Jour < 32 do 
      begin 
        result:= ''; 
        i := i; 
        Week := Week; 
        begin 
          if i = 2 then 
            begin 
              Week := Week + 1; 
              Params:=OutputDoc.Select('/document/CellS'); 
              Params:=Params.AppendChild('Cell',''); 
              Params:=Params.AppendChild('Week',''); 
             end; 
          if i = 7 then 
            begin 
              result:= Nbdays[i]; 
              i := 0; 
            end; 
          if i < 7 then 
            begin 
              Params:=Params.AppendChild('Week',''); 
              result:= result + Nbdays[i + 1]; 
              Params.AppendChild ('WeekOfMonth',IntToStr(Week)); 
              Params.AppendChild ('Days',Nbdays[DayOfWeek(i)]); 
              Params.AppendChild ('Day',IntToStr(Jour)); 
              Params.AppendChild ('Month',IntToStr(Month)); 
              Params.AppendChild ('Year',IntToStr(Year)); 
            end; 
          i := i + 1; 
          Jour := Jour + 1; 
        end; 
      end; 
    end; 
  end; 
end;