Bonsoir,

Décidemment XML et moi ça fait deux

J'ai un petit soucis lorsque je charge un fichier xml de la manière suivante dans un datagridview:

Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
private void LoadAllToDos()
        {
            MessageBox.Show("ouai");
            XmlDataDocument xmldata = new XmlDataDocument();
            MessageBox.Show("ok");
            xmldata.DataSet.ReadXmlSchema(@"./../../Data/" + Program.__ToDosXSDFile);
            MessageBox.Show("cool!!");
            xmldata.DataSet.ReadXml(@"./../../Data/" + Program.__ToDosXMLFile, XmlReadMode.ReadSchema);
            MessageBox.Show("1");
            dgvAllToDos.DataSource = xmldata.DataSet;
            MessageBox.Show("2");
            dgvAllToDos.DataMember = "item";
            MessageBox.Show("3");
        }

Les messagesbox sont la pour débuger, et en gros il va jusqu'à "cool!!" puis il bloque lors de ReadXml et m'affiche l'erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
The string 01.11.2010 is not a valid AllXsd value
Voici mon fichier XML:

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
<?xml version="1.0" encoding="utf-8"?>
<todo>
  <item id="0" project="Pif" area="AM" initiatedDate="31.10.2010" dueDate="01.11.2010">dasdasdas</item>
</todo>

Et le fichier XSD:

Code XML : 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
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="todo">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="item">
          <xs:complexType>
            <xs:attribute name="id" type="xs:int" use="optional" />
            <xs:attribute name="project" type="xs:string" use="optional" />
            <xs:attribute name="area" type="xs:string" use="optional" />
            <xs:attribute name="initiatedDate" type="xs:dateTime" use="optional" />
            <xs:attribute name="dueDate" type="xs:dateTime" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Les données sont inséré de la manière suivante:

Code C# : 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
 public static void AddToDoItem(string XMLDataFile, string text, ComboBox project, ComboBox area, DateTime initiatedDate, DateTime dueDate)
        {
            XDocument xmlFile = XDocument.Load(@"./../../Data/" + XMLDataFile);
 
            XElement item = new XElement("item",
                new XAttribute(Program.toDosFields[0].ToString(), GetXMLLastID(xmlFile) + 1),
                new XAttribute(Program.toDosFields[1].ToString(), project.SelectedValue),
                new XAttribute(Program.toDosFields[2].ToString(), area.SelectedValue),
                new XAttribute(Program.toDosFields[3].ToString(), initiatedDate.ToShortDateString()),
                new XAttribute(Program.toDosFields[4].ToString(), dueDate.ToShortDateString())
                );
 
            item.SetValue(text);
            xmlFile.Root.Add(item);
            xmlFile.Save(@"./../../Data/" + XMLDataFile);
        }

Ou est mon erreur pour qu'il me sorte le message d'erreur que j'ai? A mon avis ça doit être un problème de format de date mais je n'en suis pas sûr...

Merci bien,

L.